Socket
Socket
Sign inDemoInstall

stent

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stent - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

.babelrc

40

package.json
{
"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

README.md

@@ -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 * () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc