Comparing version 0.2.21 to 0.3.0
@@ -10,3 +10,3 @@ 'use strict'; | ||
console.log(`Current state`, state); | ||
console.log(`Previous state`, state); | ||
console.log(`Previous state`, prevState); | ||
@@ -13,0 +13,0 @@ if (typeof event === "string") { |
declare module 'robot3' { | ||
/** | ||
* TS Helpers | ||
*/ | ||
type NestedKeys<T> = T extends object | ||
? { | ||
[P in keyof T]-?: P extends string ? keyof T[P] : never | ||
}[keyof T] | ||
: never | ||
type AllStateKeys<T> = NestedKeys<T> | keyof T | ||
/** | ||
* The debugging object contains an _onEnter method, wich can be set to invoke | ||
@@ -23,3 +34,3 @@ * this function on every transition. | ||
context?: ContextFunction<C> | ||
): Machine<typeof states, C, keyof typeof states> | ||
): Machine<typeof states, C, AllStateKeys<S>> | ||
/** | ||
@@ -35,3 +46,3 @@ * The `createMachine` function creates a state machine. It takes an object of *states* with the key being the state name. | ||
context?: ContextFunction<C> | ||
): Machine<typeof states, C, keyof typeof states> | ||
): Machine<typeof states, C, AllStateKeys<S>> | ||
@@ -113,4 +124,4 @@ /** | ||
*/ | ||
export function invoke<C, T>(fn: (ctx: C) => Promise<T>, ...args: (Transition | Immediate)[]): MachineState | ||
export function invoke<C, T, E extends {} = any>(fn: (ctx: C, e?: E) => Promise<T>, ...args: (Transition | Immediate)[]): MachineState | ||
/** | ||
@@ -191,2 +202,3 @@ * The `invoke` is a special type of state that immediately invokes a Promise-returning function or another machine. | ||
export interface Service<M extends Machine> { | ||
child?: Service<M> | ||
machine: M | ||
@@ -193,0 +205,0 @@ context: M['context'] |
@@ -8,3 +8,3 @@ import { d } from './machine.js'; | ||
console.log(`Current state`, state); | ||
console.log(`Previous state`, state); | ||
console.log(`Previous state`, prevState); | ||
@@ -11,0 +11,0 @@ if (typeof event === "string") { |
{ | ||
"name": "robot3", | ||
"version": "0.2.21", | ||
"version": "0.3.0", | ||
"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
26867
636