npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thesonofthomp/recipe-parser

v0.2.1

Published

Write recipes in a Markdown-like syntax, and display them as a flowchart, [Cooking for Engineers](http://www.cookingforengineers.com) style.

Downloads

6

Readme

Recipe Parser

Write recipes in a Markdown-like syntax, and display them as a flowchart, Cooking for Engineers style.

Turn this:

Kraft Dinner
  [1] Boil: 6 cups water
  [2] Cook for 6 minutes: #1, macaroni
  [3] Drain: #2
  [4] Stir: 
    #3, 
    1/4 cup butter, 
    1/4 cup milk, 
    powdered cheese

into this:

kd-example

Check out some more live examples at thesonofthomp.com/recipes

RecipeMD syntax

Title

Add the title of your recipe as the first line of your recipe file. (this is optional)

Steps

A step is an individual action in the recipe. Declare a step using square brackets with a number (note: steps must be declared in order). Reference another step in other steps using the # character followed by the step number.

A step is made up of 2 parts, the verb, or action word, and a list of ingredients or previous steps.

Example:

[2] Cook for 6 minutes: #1, macaroni

Verbs

Include a verb as the first part of every step. End the verb text with a colon :. In the above example Cook for 6 minutes is the verb.

Ingredients

Ingredients are the subject of the step, what you're taking the action on. Ingredients can be new ingredients, or references to past steps. In the above example, #1 is a reference to a past step, and macaroni is a new ingredient.

Gotchas

Recipes must end in one step that brings all ingredients together (otherwise the chart will only display one section of the recipe). It's best to think of a recipe like a tree where the final product is the trunk, each ingredient is a leaf, and each step is a branch connecting leaves or smaller branches to the trunk.

Usage

Install the pakage from npm

npm install @thesonofthomp/recipe-parser

Utility Function

Use the utility function to parse a string into an abstract recipe object

Example:

import {parseRecipe} from '@thesonofthomp/recipe-parser'
const recipeString = 
`Kraft Dinner (Mac & Cheese)
  [1] Boil: 6 cups water
  [2] Cook for 6 minutes: #1, macaroni
  [3] Drain: #2
  [4] Stir: 
    #3, 
    1/4 cup butter, 
    1/4 cup milk, 
    powdered cheese
`
const recipeJson = parseRecipe(recipeString)

React component

To render your recipe in a React app, use the RecipeChart component. This component accepts a child string in RecipeMD syntax, or a json prop that was returned from parseRecipe.

Example:

import { RecipeComponent } from '@thesonofthomp/recipe-parser/dist/react'
// you can also import just the chart or list
import { RecipeChart, RecipeList } from '@thesonofthomp/recipe-parser/dist/react'

const myRecipe = () => {
  return (
    <RecipeComponent>
      Kraft Dinner (Mac & Cheese)
        [1] Boil: 6 cups water
        [2] Cook for 6 minutes: #1, macaroni
        [3] Drain: #2
        [4] Stir: 
          #3, 
          1/4 cup butter, 
          1/4 cup milk, 
          powdered cheese
    </RecipeComponent>
  )
}