diff --git a/README.md b/README.md index 33e0f44..fe91519 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ When in doubt simplify. ## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg) ### **BREAKING** Strong Fast Lock Step v0.1.62 * Devised a means to ensure a lock step execution of incoming actions - * Due to each stage being ran once regardless of their selector being changed, some plans may receive the wrong value if not determining if that stage has been ran for the first time. See priority.test.ts for details. + * Due to each stage being ran once regardless of their selector being changed, some plans may receive the wrong value if not determining if that stage has been ran for the first time. See priority.test.ts for the example: if (changes.length > 0) {//} * This also impacted the *axiumWaitForOpenThenIterate* helper function, but now works as intended via no longer checking for the latest lastStrategy change. ### Strong Fast Time v0.1.61 * Created the new *axiumTimeOut* helper function diff --git a/src/concepts/axium/axium.concept.ts b/src/concepts/axium/axium.concept.ts index efd48d1..4bb27d8 100644 --- a/src/concepts/axium/axium.concept.ts +++ b/src/concepts/axium/axium.concept.ts @@ -75,8 +75,8 @@ export type AxiumState = { removeConceptQue: Concept[], badPlans: Plan[]; badActions: Action[]; - timer: NodeJS.Timer[]; - tailTimer: NodeJS.Timer[]; + timer: NodeJS.Timeout[]; + tailTimer: NodeJS.Timeout[]; timerLedger: Map Action)[], number]> } diff --git a/src/model/axium.ts b/src/model/axium.ts index 6db8681..9a79117 100644 --- a/src/model/axium.ts +++ b/src/model/axium.ts @@ -155,7 +155,7 @@ export function createAxium( if (_axiumState.tailTimer.length > 0) { const timer = _axiumState.tailTimer.shift(); if (timer) { - clearTimeout(timer as NodeJS.Timeout); + clearTimeout(timer); } } const modeIndex = _axiumState.modeIndex; diff --git a/src/model/stagePlanner.ts b/src/model/stagePlanner.ts index 265f53f..c930cb5 100644 --- a/src/model/stagePlanner.ts +++ b/src/model/stagePlanner.ts @@ -35,7 +35,7 @@ export type Plan = { export type Stage = ( concepts: Concepts, dispatch: (action: Action, options: dispatchOptions, ) => void, - changes?: KeyedSelector[] + changes: KeyedSelector[] ) => void; export type Staging = { diff --git a/src/model/time.ts b/src/model/time.ts index 2442354..cc5e449 100644 --- a/src/model/time.ts +++ b/src/model/time.ts @@ -45,7 +45,7 @@ export const axiumTimeOut = (concepts: Concepts, func: () => Action, timeOut: nu // If timer exists, first index of timerList would exist const timerList = Object.keys(ledger).map(t => Number(t)).sort((a, b) => a - b); if (timerList[0] > timed) { - clearTimeout(timer as NodeJS.Timeout); + clearTimeout(timer); axiumState.timer.shift(); const slot = axiumState.timerLedger.get(timed); if (slot) { diff --git a/src/test/priority/priority.test.ts b/src/test/priority/priority.test.ts index 4c8ded8..beaa0b3 100644 --- a/src/test/priority/priority.test.ts +++ b/src/test/priority/priority.test.ts @@ -23,7 +23,7 @@ test('Priority Test', (done) => { concluded++; } }; - const firstRun = [true, true, true]; + const priorityTest = createAxium('Priority Test', [ createExperimentPriorityConcept() ], true, true, true); @@ -47,17 +47,15 @@ test('Priority Test', (done) => { }); } }, {priority}); - const thirdStage = (name: string, expected: number, priority: number, pos: number) => createStage((concepts, dispatch) => { + const thirdStage = (name: string, expected: number, priority: number) => createStage((concepts, dispatch, changes) => { const priorityState = select.state(concepts, experimentName); - if (priorityState && !firstRun[pos]) { + if (priorityState && changes.length > 0) { // expect(order).toBe(expectedOrder); console.log(`${name} Incoming Value: ${priorityState.value}, expecting: ${expected}`); // expect(priorityState.value).toBe(expected); dispatch(axiumKick(), { iterateStage: true }); - } else { - firstRun[pos] = false; } }, {selectors: [experimentPriorityValueSelector], priority}); const concludePlan = (name: string, func: () => StagePlanner) => createStage(() => { @@ -72,7 +70,7 @@ test('Priority Test', (done) => { 'Low Priority Plan', [ firstStage(LOW, LOW_PRIORITY), secondStage(LOW, 1, LOW_PRIORITY), - thirdStage(LOW, 111, LOW_PRIORITY, 0), + thirdStage(LOW, 111, LOW_PRIORITY), concludePlan(LOW, () => low), ]); const HIGH = 'High'; @@ -81,7 +79,7 @@ test('Priority Test', (done) => { 'High Priority Plan', [ firstStage(HIGH, HIGH_PRIORITY), secondStage(HIGH, 100, HIGH_PRIORITY), - thirdStage(HIGH, 100, HIGH_PRIORITY, 1), + thirdStage(HIGH, 100, HIGH_PRIORITY), concludePlan(HIGH, () => high), ]); const MID = 'Mid'; @@ -90,7 +88,7 @@ test('Priority Test', (done) => { 'Mid Priority Plan', [ firstStage(MID, MID_PRIORITY), secondStage(MID, 10, MID_PRIORITY), - thirdStage(MID, 110, MID_PRIORITY, 2), + thirdStage(MID, 110, MID_PRIORITY), concludePlan(MID, () => mid), ]); setTimeout(() => {