node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



State is a JavaScript library for implementing first-class states on arbitrary owner objects.

A State is a module of behavior โ€” expressed as definitions of methods, data, and/or events โ€” that can be exhibited by its owner. The State object model provides for hierarchical, compositional, and indirect prototypal relations between States, facilitating a variety of patterns for reuse and modularity.

An owner object exhibits the behavior expressed by its current state โ€” method calls the owner receives are automatically dispatched to methods defined or inherited by that State. Behavior of the owner is altered by executing transitions that carry its current state reference from one of its States to another.

Visit for an introduction, with sample code, comprehensive documentation including a getting started guide and conceptual overview, API reference, and annotated source.