Update readme, run prettier

This commit is contained in:
Reece Dunham committed 2022-03-30 12:39:46 -04:00
1 parent a219a41fb3
commit 8151cc76a5
4 files changed
+40 -16

No files matched your search

+12 -4
View File
@@ -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.
)
```
+5 -1
View File
@@ -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}!`)
}
+8 -5
View File
@@ -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)
+15 -6
View File
@@ -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)