Skip to content

Commit

Permalink
Run prettier, remove the object.hasOwnProperty stuff (it's not needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
RDIL committed Jul 23, 2024
1 parent c095214 commit 3e8de1a
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 86 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ const result = test(
Value: {
Greeting: "Hi!",
},
} // the variables object, which is essentially the input values.
}, // the variables object, which is essentially the input values.
)
```
20 changes: 9 additions & 11 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ Example:
```json5
{
$after: 5,
} // -> return `true` after 5 seconds
}
// -> return `true` after 5 seconds
```

### `$inarray`, `$any`
Expand Down Expand Up @@ -483,19 +484,16 @@ Example:
// for each number in the `input` context object that is equal to 1, add 5 to the counter
{
$select: {
"in": "$.input",
in: "$.input",
"?": {
$eq: [
"$.#",
1
]
$eq: ["$.#", 1],
},
"!": [
{
$inc: ["counter", 5]
}
]
}
$inc: ["counter", 5],
},
],
},
}
```

Expand Down Expand Up @@ -530,7 +528,7 @@ Let's instead rewrite it with a nested loop:
// PoisonKills - a list of target IDs that have been killed with poison

{
// this is the outer loop, which checks each target. this means that
// this is the outer loop, which checks each target. this means that
$all: {
// Targets would be a context variable like `["target-1-repo-id", "target-2-repo-id"]`
in: "$.Targets",
Expand Down
4 changes: 2 additions & 2 deletions src/arrayHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function handleArrayLogic<Variables>(
input: any,
variables: Variables,
op: string,
options: TestOptions
options: TestOptions,
): boolean {
// find the array
const array = realTest(input[op]["in"], variables, {
Expand All @@ -52,7 +52,7 @@ export function handleArrayLogic<Variables>(
findNamedChild(reference, variables) {
// NOTE: if we have a multi-layered loop, this should one-by-one fall back until the targeted loop is hit
const hashtags = fillHashtags(
(options._currentLoopDepth || 0) + 1
(options._currentLoopDepth || 0) + 1,
)

// a little future-proofing, as sometimes the $ is there, and other times it isn't.
Expand Down
22 changes: 11 additions & 11 deletions src/handleEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
definition: StateMachineLike<Partial<Context>>,
context: Partial<Context>,
event: Event,
options: HandleEventOptions
options: HandleEventOptions,
): HandleEventReturn<Partial<Context>> {
const log = options.logger || (() => {})

Expand All @@ -49,7 +49,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
if (!csObject || (!csObject?.[eventName] && !csObject?.$timer)) {
log(
"disregard-event",
`SM in state ${currentState} disregarding ${eventName}`
`SM in state ${currentState} disregarding ${eventName}`,
)
// we are here because either:
// - we have no handler for the current state
Expand All @@ -73,7 +73,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
// IOI sometimes puts the actions along-side keys like Transition and Condition,
// yet both still apply
const irregularEventKeys = Object.keys(handler).filter((k) =>
k.includes("$")
k.includes("$"),
)
const hasIrregularEventKeys = irregularEventKeys.length > 0

Expand Down Expand Up @@ -103,12 +103,12 @@ export function handleEvent<Context = unknown, Event = unknown>(
const referenceArray = findNamedChild(
reference,
newContext,
true
true,
)
item = findNamedChild(item, newContext, false)
log(
"action",
`Running pushUniqueAction on ${reference} with ${item}`
`Running pushUniqueAction on ${reference} with ${item}`,
)

if (!Array.isArray(referenceArray)) {
Expand All @@ -128,7 +128,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
logger: log,
timers: options.timers,
eventTimestamp: options.timestamp,
}
},
)
}

Expand All @@ -143,7 +143,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
;(<unknown[]>Actions).push(
...irregularEventKeys.map((key) => {
return { [key]: handler[key] }
})
}),
)
}

Expand All @@ -163,7 +163,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
},
{
originalContext: definition.Context ?? {},
}
},
)
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ export function handleEvent<Context = unknown, Event = unknown>(

log(
"transition",
`${currentState} is performing a transition to ${state} - running its "-" event`
`${currentState} is performing a transition to ${state} - running its "-" event`,
)

// When transitioning, we have to reset all timers.
Expand All @@ -215,7 +215,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
timers: options.timers,
timestamp: options.timestamp,
contractId: options.contractId,
}
},
)
}

Expand Down Expand Up @@ -272,7 +272,7 @@ export function handleEvent<Context = unknown, Event = unknown>(
if (timerResult) {
log(
"timer",
"Timer caused a state transition, replaying current event with new state."
"Timer caused a state transition, replaying current event with new state.",
)

options.currentState = timerResult.state
Expand Down
Loading

0 comments on commit 3e8de1a

Please sign in to comment.