Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Phaze is a finite state machine for Node robotics. It is intended to help manage the transitions from one state to the next in a deterministic manner.
Some basics to consider when using a state machine:
A stimulus is required to initiate a transition - this can be an event or an explicit call to change state.
/***************
STATES
***************/
var startState = {
do: function () {
},
outputEvent: 'startEvent'
};
var walkingState = {
do: function (callback) {
callback(null, 'Walking...');
},
outputEvent: 'walkEvent'
};
// no outputEvent will cause the state machine to exit the loop
var runningState = {
do: function (callback) {
callback(null, 'Running...');
}
};
/***************
TRANSITIONS
***************/
var transition1 = {
eventId: 'startEvent',
from: ['startState'],
to: 'walkingState'
};
var transition2 = {
eventId: 'walkEvent',
from: ['walkingState'],
to: 'runningState'
};
/***************
STATE PERSISTENCE FUNCTIONS (these can wrap database calls etc.)
***************/
var getStateFunc = function (callback) {
callback(null, 'startState');
};
var saveStateFunc = function (state, callback) {
callback();
};
/***
STATE MACHINE
***/
var stateMachine = new StateMachine();
// initialise - first argument is the number of times the machine will loop (0 = infinite)
stateMachine.initialise(1, getStateFunc, saveStateFunc, function (err) {
if (err)
return done(err);
stateMachine.addState('startState', startState);
stateMachine.addState('walkingState', walkingState);
stateMachine.addState('runningState', runningState);
stateMachine.addTransition(transition1);
stateMachine.addTransition(transition2);
// start the machine and confirm the final result
stateMachine.start('startEvent', function (err, result) {
if (err)
return done(err);
expect(result).to.equal('Running...');
done();
})
});
FAQs
Finite state machine for Node robotics
The npm package phaze receives a total of 3 weekly downloads. As such, phaze popularity was classified as not popular.
We found that phaze demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.