Skip to content

Commit 9c2b4fe

Browse files
committed
Cleanup
1 parent 18d10fd commit 9c2b4fe

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

justin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { err } from "./parse.js"
22

33
// build optimized evaluator for the tree
4-
export const compile = (node) => !Array.isArray(node) ? compile.id(node) : !node[0] ? () => node[1] : operators[node[0]](...node.slice(1)),
4+
export const compile = (node) => !Array.isArray(node) ? compile.id(node) : !node[0] ? () => node[1] : operators[node[0]].call(...node),
55
// compile id getter
66
id = compile.id = name => ctx => ctx?.[name],
77

8-
98
// registered operators
109
operators = {},
1110

src/parse.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ export let idx, cur,
66
// no handling tagged literals since easily done on user side with cache, if needed
77
parse = s => (idx = 0, cur = s, s = expr(), cur[idx] ? err() : s || ''),
88

9+
// display error
910
err = (msg = 'Bad syntax',
1011
lines = cur.slice(0, idx).split('\n'),
1112
last = lines.pop()
1213
) => {
13-
let before = cur.slice(idx - 108, idx).split('\n').pop()
14-
let after = cur.slice(idx, idx + 108).split('\n').shift()
14+
const before = cur.slice(idx - 108, idx).split('\n').pop()
15+
const after = cur.slice(idx, idx + 108).split('\n').shift()
1516
throw EvalError(`${msg} at ${lines.length}:${last.length} \`${idx >= 108 ? '…' : ''}${before}${after}\``, 'font-weight: bold')
1617
},
1718

0 commit comments

Comments
 (0)