From 3290af93faa50c5c87e5eb7f7dbf0c87c5b934c0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 13 Jul 2025 20:29:31 -0300 Subject: Hoist `numFromDigits()` before its usage * src/paca.mjs (numFromDigits): Move it to before the *StateStep functions, as it is now used in `rangeStateStep()` function. So instead of letting it be defined afters its usage, move it up. * tests/paca.mjs: Do the same hoisting to the import of the `numFromDigits` name, to the definition of `test_numFromDigits` and its inclusion in the order of the call to `runTests()`. --- src/paca.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/paca.mjs b/src/paca.mjs index 6843c20..c5102c3 100644 --- a/src/paca.mjs +++ b/src/paca.mjs @@ -12,6 +12,11 @@ const ConcatStep = { RANGE: "range", }; +const numFromDigits = digits => + digits.length === 0 + ? -1 + : Number(digits.join("")); + const escapingStateStep = ({ out, state, context }, char, index, next) => ({ out: out.concat( char, @@ -149,11 +154,6 @@ const shouldConcat = (char, next) => const isOperator = char => nonConcatOperators.has(char) || char == "("; -const numFromDigits = digits => - digits.length === 0 - ? -1 - : Number(digits.join("")); - const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => { const next = chars[index + 1]; -- cgit v1.2.3