fn-machine
Advanced tools
Comparing version 0.0.3 to 0.0.5
{ | ||
"name": "fn-machine", | ||
"version": "0.0.3", | ||
"version": "0.0.5", | ||
"description": "a tiny functional state machine", | ||
"main": "index.js", | ||
"main": "index", | ||
"directories": { | ||
@@ -12,3 +12,4 @@ "example": "example" | ||
"type-check": "tsc --noEmit", | ||
"release": "npm run type-check && np" | ||
"release": "npm run type-check && np", | ||
"build-typings": "tsc -p tsconfig-typings.json" | ||
}, | ||
@@ -33,4 +34,8 @@ "repository": { | ||
"np": "^5.0.3", | ||
"sinon": "^7.3.2" | ||
} | ||
"sinon": "^7.3.2", | ||
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/41996/artifacts?artifactName=tgz&fileId=967EC7B6DC9AAC54797655C1C1403FFCE2BEBB49FBAD58A0AC397F5F2F10AEE202&fileName=/typescript-3.7.0-insiders.20190829.tgz" | ||
}, | ||
"files": [ | ||
"src/*" | ||
] | ||
} |
### fn-machine | ||
A tiny, functional state machine implementation | ||
A tiny, functional, state machine utility | ||
#### install | ||
... | ||
`npm install fn-machine` | ||
#### usage | ||
see example | ||
see [example](https://github.com/jrobinson01/fn-machine/blob/master/example/index.html) |
@@ -1,13 +0,5 @@ | ||
/** | ||
* @typedef CurrentState | ||
* @property {string} state | ||
* @property {Object} context | ||
*/ | ||
/** @typedef {import('./fn-state').CurrentState} CurrentState */ | ||
/** @typedef {import('./fn-state').State} State */ | ||
// annoyingly, this typedef has to be duplicated from fn-state.js?? | ||
/** | ||
* @typedef {{name:string, transitions:Object, enter:function, exit:function}} State | ||
*/ | ||
/** | ||
/** | ||
* @description define a state machine | ||
@@ -14,0 +6,0 @@ * @param {Array<!State>} states |
/** | ||
* @typedef {Object.<string, function(Object, Object):Object>} Transition | ||
* @typedef {{state:string, context?:any}} CurrentState | ||
*/ | ||
/** | ||
* @typedef {{name:string, transitions:Object, enter:function, exit:function}} State | ||
* @typedef {function(Object, Object):CurrentState} Transition | ||
*/ | ||
/** | ||
* @typedef {{name:string, transitions:Object.<string, Transition>, enter:function, exit:function}} State | ||
*/ | ||
/** | ||
* @description define a single state | ||
* @param {string} name | ||
* @param {Object.<string, Transition>=} transitions | ||
* @param {function=} enterFn | ||
* @param {function=} exitFn | ||
* @param {Object.<string, Transition>} transitions | ||
* @param {function(Object)=} enterFn | ||
* @param {function(Object)=} exitFn | ||
* @return {!State} | ||
*/ | ||
export default function state(name, transitions = {}, enterFn = () => {}, exitFn = () => {}) { | ||
export default function state(name, transitions, enterFn = () => {}, exitFn = () => {}) { | ||
return {name, transitions, enter: enterFn, exit: exitFn}; | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6189
6
6
163
1