feat(js): m10 extensions (pause, restart, speed-up via Frame) with tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-28 23:56:49 +01:00
co-authored by Claude Sonnet 5.5
parent 25141ce86d
commit fd7c5f2acf
13 changed files with 1347 additions and 17 deletions
+7 -1
View File
@@ -8,5 +8,11 @@ const directions = {
ArrowRight: 'Right', d: 'Right', D: 'Right',
}
// Keys that are not steering (m10).
const commands = { ' ': Action.TogglePause, r: Action.Restart, R: Action.Restart }
// hasOwn, not `key in table`: "constructor" and "toString" are inherited properties, not keys we mapped.
export const keyToAction = (key) =>
Object.hasOwn(directions, key) ? Action.Turn(directions[key]) : null
Object.hasOwn(directions, key) ? Action.Turn(directions[key])
: Object.hasOwn(commands, key) ? commands[key]
: null