Comparing version 0.2.3 to 0.2.4
@@ -7,3 +7,6 @@ import { d } from './machine.js'; | ||
d._create = function(states) { | ||
d._create = function(current, states) { | ||
if(!(current in states)) { | ||
throw new Error(`Initial state [${current}] is not a known state.`); | ||
} | ||
for(let p in states) { | ||
@@ -10,0 +13,0 @@ let state = states[p]; |
@@ -9,3 +9,6 @@ 'use strict'; | ||
machine.d._create = function(states) { | ||
machine.d._create = function(current, states) { | ||
if(!(current in states)) { | ||
throw new Error(`Initial state [${current}] is not a known state.`); | ||
} | ||
for(let p in states) { | ||
@@ -12,0 +15,0 @@ let state = states[p]; |
@@ -135,5 +135,10 @@ 'use strict'; | ||
}; | ||
function createMachine(states, contextFn = empty) { | ||
if(d._create) d._create(states); | ||
let current = Object.keys(states)[0]; | ||
function createMachine(current, states, contextFn = empty) { | ||
if(typeof current !== 'string') { | ||
contextFn = states || empty; | ||
states = current; | ||
current = Object.keys(states)[0]; | ||
} | ||
if(d._create) d._create(current, states); | ||
return create(machine, { | ||
@@ -140,0 +145,0 @@ context: valueEnumerable(contextFn), |
@@ -131,5 +131,10 @@ function valueEnumerable(value) { | ||
}; | ||
export function createMachine(states, contextFn = empty) { | ||
if(d._create) d._create(states); | ||
let current = Object.keys(states)[0]; | ||
export function createMachine(current, states, contextFn = empty) { | ||
if(typeof current !== 'string') { | ||
contextFn = states || empty; | ||
states = current; | ||
current = Object.keys(states)[0]; | ||
} | ||
if(d._create) d._create(current, states); | ||
return create(machine, { | ||
@@ -136,0 +141,0 @@ context: valueEnumerable(contextFn), |
{ | ||
"name": "robot3", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A function, immutable Finite State Machine library", | ||
@@ -5,0 +5,0 @@ "main": "dist/machine.js", |
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
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
15676
387