Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

robot3

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robot3 - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

readme.md

19

machine.js

@@ -13,5 +13,4 @@ function valueEnumerable(value) {

let identity = a => a;
let identity2 = (a, b) => b;
let callBoth = (par, fn, self, args) => par.apply(self, args) && fn.apply(self, args);
let callForward = (par, fn, self, [a, b]) => fn.call(self, a, par.call(self, a, b));
let callForward = (par, fn, self, [a, b]) => fn.call(self, par.call(self, a, b), b);
let create = (a, b) => Object.freeze(Object.create(a, b));

@@ -31,5 +30,2 @@

let actionType = {};
export let action = fnType.bind(actionType);
let reduceType = {};

@@ -47,3 +43,3 @@ export let reduce = fnType.bind(reduceType);

let guards = stack(filter(guardType, args).map(t => t.fn), truthy, callBoth);
let reducers = stack(filter(reduceType, args).map(t => t.fn), identity2, callForward);
let reducers = stack(filter(reduceType, args).map(t => t.fn), identity, callForward);
return [guards, reducers];

@@ -111,3 +107,3 @@ }

return function() {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
this.child = interpret(machine, s => {

@@ -137,7 +133,7 @@ this.onChange(s);

};
export function createMachine(states, contextFn) {
export function createMachine(states, contextFn = empty) {
if(d._create) d._create(states);
let current = Object.keys(states)[0];
return create(machine, {
context: valueEnumerable(contextFn || empty),
context: valueEnumerable(contextFn),
current: valueEnumerable(current),

@@ -152,3 +148,3 @@ states: valueEnumerable(states)

if(guards(context)) {
service.context = reducers.call(service, fromEvent, context);
service.context = reducers.call(service, context, fromEvent);

@@ -186,2 +182,3 @@ let original = machine.original || machine;

};
export function interpret(machine, onChange) {

@@ -196,2 +193,2 @@ let s = Object.create(service, {

return s;
}
}
{
"name": "robot3",
"version": "0.1.0",
"version": "0.2.0",
"description": "A function, immutable Finite State Machine library",

@@ -13,2 +13,4 @@ "main": "machine.js",

"scripts": {
"minify": "terser machine.js -o machine.min.js",
"bundlesize": "npm run minify && bundlesize --config bundlesize.json",
"server": "http-server -p 1965",

@@ -21,3 +23,5 @@ "test": "node-qunit-puppeteer http://localhost:1965/test/test.html 10000"

},
"keywords": ["Finite State Machine"],
"keywords": [
"Finite State Machine"
],
"author": "Matthew Phillips <matthew@matthewphillips.info>",

@@ -32,7 +36,9 @@ "license": "BSD-2-Clause",

"@11ty/eleventy-plugin-syntaxhighlight": "^2.0.3",
"bundlesize": "^0.18.0",
"http-server": "^0.11.1",
"markdown-it": "^9.1.0",
"markdown-it-toc-and-anchor": "^4.2.0",
"node-qunit-puppeteer": "^1.0.13"
"node-qunit-puppeteer": "^1.0.13",
"terser": "^4.3.1"
}
}
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