diff --git a/README.md b/README.md index 4a9fe9c..810260e 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,18 @@ yarn && yarn build ## Usage ```js -const { check } = require("@peacockproject/statemachine-parser") +const { test } = require("@peacockproject/statemachine-parser") -const result = check( - { $eq: [true, true] }, // the state machine condition - { Value: {} } // the globals object, which is essentially the input values. +const condition = { + $eq: ["$Value.Greeting", "Hi!"], +} + +const result = test( + condition, // the state machine condition + { + Value: { + Greeting: "Hi!", + }, + } // the variables object, which is essentially the input values. ) ``` diff --git a/src/timers.ts b/src/timers.ts index 4743d1a..ee398f6 100644 --- a/src/timers.ts +++ b/src/timers.ts @@ -40,7 +40,11 @@ export class Timer { * @param newState The new state value. */ set state(newState: TimerStatus) { - if (newState !== TIMER_CANCELLED && newState !== TIMER_RUNNING && newState !== TIMER_COMPLETE) { + if ( + newState !== TIMER_CANCELLED && + newState !== TIMER_RUNNING && + newState !== TIMER_COMPLETE + ) { throw new TypeError(`Invalid timer state: ${newState}!`) } diff --git a/tests/after.spec.ts b/tests/after.spec.ts index ab74200..6d9686f 100644 --- a/tests/after.spec.ts +++ b/tests/after.spec.ts @@ -12,8 +12,8 @@ const data = { { $after: 5, }, - {} - ] + {}, + ], } it("returns false with no timer manager specified", () => { @@ -38,9 +38,12 @@ it("doesn't return true until a 5 second timer is up", function testTimers5(done return done() } - assert.strictEqual(test(sm, globals, { - timerManager: tm, - }), false) + assert.strictEqual( + test(sm, globals, { + timerManager: tm, + }), + false + ) setTimeout(() => { assert.strictEqual(test(sm, globals, { timerManager: tm }), false) diff --git a/tests/timers.spec.ts b/tests/timers.spec.ts index 46ef15d..395d43f 100644 --- a/tests/timers.spec.ts +++ b/tests/timers.spec.ts @@ -1,4 +1,10 @@ -import { test, TimerManager, TIMER_RUNNING, TIMER_CANCELLED, Timer } from "../src" +import { + test, + TimerManager, + TIMER_RUNNING, + TIMER_CANCELLED, + Timer, +} from "../src" import assert from "assert" const data = { @@ -6,8 +12,8 @@ const data = { { $after: 5, }, - {} - ] + {}, + ], } describe("timer managers", () => { @@ -22,7 +28,7 @@ describe("timer managers", () => { this.timers.set(path, t) return t } - }) + })() assert.strictEqual(timerManager.timers.size, 0) @@ -30,7 +36,10 @@ describe("timer managers", () => { assert.strictEqual(timerManager.timers.size, 1) - assert.strictEqual(timerManager.timers.values().next().value.state, TIMER_RUNNING) + assert.strictEqual( + timerManager.timers.values().next().value.state, + TIMER_RUNNING + ) }) it("can cancel timers", (done) => { @@ -42,7 +51,7 @@ describe("timer managers", () => { this.timers.set(path, t) return t } - }) + })() assert.strictEqual(timerManager.timers.size, 0)