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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fizbin

v0.8.3

Published

finite state machine

Readme

fizbin

Finite state machine

Example

var fizbin = require('fizbin');


var FsmFactory = fizbin.FsmFactory;
var fsm        = fizbin.fsm;


// instantiate class with a sealed statemachine as an instance value
function SecurityLight(id)
{
  this.fsm = SecurityLight.factory.create(id, this);  // create an fsm instance
}

// define a class method to create a factory for SecurityLight fsm
SecurityLight.factorize = function() {
  SecurityLight.factory = new FsmFactory(SecurityLight);
};

SecurityLight.prototype = {
  constructor: SecurityLight
  
  // behaviors can be associated states by defining methods named for entering or exiting a specific state
  ,enter: say  // generic state entry logging
  ,exit: said  // generic state exit logging
  // ,enterOn: function() { log('I am on');  }
  // ,exitOn: function()  { log('I am off'); }
};

// this is the specification of the state machine. It is totally independent of associated behavior
SecurityLight.config =
{
   start:   'Night'                   // initial state
  ,states: ['Day', 'Night', 'On']     // our set of states

  //---- io section defines signals (events are still union of those mentioned in transitions) ----
  ,io:
  {
    ambientLight: fsm.logical,
    temperature: fsm.numeric
  }

  // all the possible ways to get from one state to another
  // fsm compiler guarantees that all states mentioned are in the states array
  // and that all terms mentioned in condition expression (when) are declared as variables in the io section
  ,transitions:
    [
       {from: 'Day',          to: 'Night',  when:'!ambientLight'} // transition on variable changes
      ,{from: ['Night','On'], to: 'Day',    when: 'ambientLight'}  
      ,{from: ['Night','On'], to: 'On',      evt: 'motion'      } // transition on receiving event tokens
      ,{from: 'On',           to: 'Night', timer: 5000          } // fizbin generates timer based events
    ]

  ,options:{}
};

SecurityLight.factorize();

var sl1 = new SecurityLight('sl-1');

// sending an event manually from the outside sl1.fsm.transduce('motion');
// setting a variable sl1.fsm.ambientLight(true);