Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "stent", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Stent is a state machines container made for UI development", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "npm run coverage && npm run test && babel src --out-dir lib && browserify ./lib/index.js -o ./standalone/stent.js --standalone stent && uglifyjs ./standalone/stent.js -o ./standalone/stent.min.js", | ||
"test": "./node_modules/.bin/mocha --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter spec --slow 100 './src/**/**.spec.{js,jsx}'", | ||
"test:watch": "./node_modules/.bin/mocha --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter spec --slow 100 --watch --watch-extensions jx,jsx,json './src/**/**.spec.{js,jsx}'", | ||
"t": "mocha ./test/setup.js ./test/specs/**/*.spec.js", | ||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter xunit --reporter-options output=reports/test-results.xml './src/**/**.spec.{js,jsx}'" | ||
}, | ||
@@ -15,5 +19,6 @@ "repository": { | ||
"state", | ||
"stent", | ||
"finite", | ||
"state", | ||
"machine" | ||
"machine", | ||
"stent" | ||
], | ||
@@ -25,3 +30,26 @@ "author": "Krasimir Tsonev", | ||
}, | ||
"homepage": "https://github.com/krasimir/stent#readme" | ||
"homepage": "https://github.com/krasimir/stent#readme", | ||
"devDependencies": { | ||
"babel-cli": "6.24.0", | ||
"babel-plugin-add-module-exports": "0.2.0", | ||
"babel-polyfill": "6.23.0", | ||
"babel-preset-es2015": "6.22.0", | ||
"babel-preset-react": "6.23.0", | ||
"babel-preset-stage-3": "6.22.0", | ||
"babel-register": "6.24.0", | ||
"browserify": "^14.4.0", | ||
"chai": "3.5.0", | ||
"chai-enzyme": "0.6.1", | ||
"enzyme": "2.7.1", | ||
"istanbul": "1.1.0-alpha.1", | ||
"jsdom": "9.8.3", | ||
"jsdom-global": "2.1.1", | ||
"mocha": "3.2.0", | ||
"react": "15.4.2", | ||
"react-addons-test-utils": "15.4.2", | ||
"react-dom": "15.4.2", | ||
"sinon": "2.0.0", | ||
"sinon-chai": "2.9.0", | ||
"uglify-js": "^3.0.28" | ||
} | ||
} |
@@ -22,3 +22,3 @@ # Stent | ||
The library is available as a [npm module](https://www.npmjs.com/package/stent) so `npm install stent` will do the job. There's also a standalone version [here](./lib/stent.js) (only core functionalities) which you can directly add to your page. | ||
The library is available as a [npm module](https://www.npmjs.com/package/stent) so `npm install stent` will do the job. There's also a standalone version [here](./standalone/stent.js) (only core functionalities) which you can directly add to your page. | ||
@@ -149,3 +149,3 @@ ## A few words about state machines | ||
### `Machine.create` and `Machine.get` | ||
### `Machine.<create|get|flush>` | ||
@@ -186,2 +186,4 @@ The `Machine` object is used for creating and fetching machines. | ||
`Machine.flush()` can be used to delete the currently created machines. | ||
### `<action handler>` | ||
@@ -214,3 +216,3 @@ | ||
'idle': { | ||
'fetch data': function () { | ||
'fetch data': function (state, payload) { | ||
return 'fetching'; | ||
@@ -222,2 +224,4 @@ } | ||
Notice that the function receives the current state and some payload passed when the action is called. | ||
And of course we may return the actual state object. That's actually a common case because very often we want to keep some data alongside: | ||
@@ -228,3 +232,3 @@ | ||
'idle': { | ||
'fetch data': function () { | ||
'fetch data': function (state, payload) { | ||
return { name: 'fetching', answer: 42 }; | ||
@@ -241,3 +245,3 @@ } | ||
'idle': { | ||
'fetch data': function () { | ||
'fetch data': function (state, payload) { | ||
if (this.isIdle()) { | ||
@@ -254,2 +258,4 @@ this.request('/api/todos'); | ||
In some cases you don't want to change the state but only handle the action. So feel free to skip the `return` statement. If the handler returns `undefined` the machine keeps its state. | ||
We may also use a generator if we have more complex operations or/and async tasks. | ||
@@ -260,3 +266,3 @@ | ||
'idle': { | ||
'fetch data': function * () { | ||
'fetch data': function * (state, payload) { | ||
yield 'fetching'; // transition to a `fetching` state | ||
@@ -462,6 +468,6 @@ yield { name: 'fetching' } // the same but using a state object | ||
todos.push(todo); | ||
return { todos }; | ||
return { name: 'idle', todos }; | ||
}, | ||
'delete todo': function ({ todos }, index) { | ||
return { todos: todos.splice(index, 1) }; | ||
return { name: 'idle', todos: todos.splice(index, 1) }; | ||
}, | ||
@@ -468,0 +474,0 @@ 'fetch todos': function * () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
201882
34
1098
531
21
4