hierarchical object states
npm install entity/states
component install entity/states
var states = require('states');
var entity = states();
entity('human', {
speak: function(){
return 'hello, world';
}
});
entity('doge', {
speak: function(){
return 'such world, wow';
}
});
entity.push('human');
console.log(entity.speak()); // => 'hello, world'
entity.push('doge');
console.log(entity.speak()); // => 'such world, wow'
entity.pop();
console.log(entity.speak()); // => 'hello, world'
Factory state
.
Define state s
with obj
.
Push state s
to stack.
Pop state from stack.
MIT