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

@stating/builder

v0.1.0

Published

Help build nodes for stating

Downloads

1

Readme

@stating/builder

Build Status Dependency Status npm version Coverage Status

Help build nodes for stating.

Each stating node is a function. This package helps build common node functions.

See stating package to learn about how these nodes are added to a stating instance.

Install

npm install --save @stating/builder

Usage

// returns a builder function
var buildBuilder = require('@stating/builder')

// build a new builder to add plugins to and use
var builder = buildBuilder()

// add a plugin which provides a static string consumer node.
builder.use('@stating/string-plugin')

// now build a node to match the word "true"
var trueNode = builder.string('true')

// trueNode is a function which will wait for 4 bytes of input
// and then test if the next 4 bytes is 'true'.
// it will control.fail() if it's not.
// it will control.next() if it is.

// add it to your stating instance:
stating.add('true', trueNode)

// create others ...
// and add more plugins and use them...

// load some plugins when building it:
builder = buildBuilder({

  // if some plugins to load are local modules set the root:
  root: __dirname,

  // provide shared options to plugins:
  options: {},

  load: [
    // list stuff to load.
    // the same things you'd provide to builder.use()
  ]
})

Plugins

  1. @stating/string-plugin
  2. TODO: more plugins...
  3. feel free to ask to contribute plugins to the @stating scope

Make a Plugin

Here's a super simple example to see the three parts:

  1. the exported plugin function for builder.use()
  2. the exported build function placed onto the builder
  3. a stating node function which is used repeatedly
// see `stating` package for what to do in a node.
// this one simply calls next(). it does nothing really.
function next(control, nodes) {
  // NOTE: this would do analysis work and choose to
  // wait() next() or fail()...
  control.next()
}

// the build function added to the builder by this plugin.
// it returns the same node function all the time.
function myBuild() {
  // NOTE: this could generate a closure based on
  // the args provided.
  return someFn
}

// export the plugin function added to @stating/builder
module.exports = function myPlugin(options, builder) {
  // simply add the build function to the builder
  builder.myBuild = myBuild

  // NOTE:
  //  could do more work here. make closures.
  //  assign multiple functions.
  //  some functions could rely on others by using `this`
  //  in them.
}

Debugging Breakpoint

To add a debugging breakpoint wrap the generated function and set a breakpoint.

function wrappedTrueNode(control, N, context) {
  // set a breakpoint here... then step into trueNode.
  trueNode.call(context, control, N, context)  
}

// add the wrapped version instead.
stating.add('true', wrappedTrueNode)

MIT License