diff options
author | William Carroll <wpcarro@gmail.com> | 2023-01-19T23·19-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-19T23·23+0000 |
commit | 148a63ae7e2633b69446372fa9ee475fa7a9eb0a (patch) | |
tree | a638622dfe9e9e2cae49c108e9faa76e188472a6 /users/wpcarro/slx.js/index.js | |
parent | 509e356bb8fcba2264368ca1e973e270ab614f98 (diff) |
fix(wpcarro/slx): Forward config to all functions r/5705
Oops... Change-Id: I985a1a10e3009107ca2b8f65e5377f36fe0531fa Reviewed-on: https://cl.tvl.fyi/c/depot/+/7875 Autosubmit: wpcarro <wpcarro@gmail.com> Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
Diffstat (limited to 'users/wpcarro/slx.js/index.js')
-rw-r--r-- | users/wpcarro/slx.js/index.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/users/wpcarro/slx.js/index.js b/users/wpcarro/slx.js/index.js index 7eba2dca91bf..9f2ed675f7a9 100644 --- a/users/wpcarro/slx.js/index.js +++ b/users/wpcarro/slx.js/index.js @@ -1,12 +1,12 @@ function select(query, xs, config) { - const predicate = compile(parse(query), config); + const predicate = compile(parse(query, config), config); return xs.filter(predicate); } function compile(ast, config) { if (ast.type === 'CONJUNCTION') { - const lhs = compile(ast.lhs); - const rhs = compile(ast.rhs); + const lhs = compile(ast.lhs, compile); + const rhs = compile(ast.rhs, compile); if (ast.joint === 'AND') { return function(x) { @@ -50,7 +50,7 @@ function compile(ast, config) { } } if (ast.type === 'SELECTION') { - const f = compile(ast.val); + const f = compile(ast.val, config); return function(row) { return ast.negate ? !f(row[ast.key]) : f(row[ast.key]); }; @@ -225,16 +225,16 @@ function parser(tokens) { return { i: 0, tokens }; } -function parse(x) { +function parse(x, config) { const tokens = tokenize(x); const p = parser(tokens); - return conjunction(p); + return conjunction(p, config); } -function conjunction(p) { +function conjunction(p, config) { skipWhitespace(p); - const lhs = selection(p); + const lhs = selection(p, config); skipWhitespace(p); if (p.i >= p.tokens.length) { @@ -250,7 +250,7 @@ function conjunction(p) { p.i += 1; } skipWhitespace(p); - let rhs = conjunction(p); + let rhs = conjunction(p, config); return { type: 'CONJUNCTION', @@ -267,7 +267,7 @@ function peekType(n, p) { return null; } -function selection(p) { +function selection(p, config) { // column:value OR -column:value if ((peekType(0, p) === 'ATOM' && peekType(1, p) === 'COLON') || (peekType(0, p) === 'NEGATE' && peekType(1, p) === 'ATOM' && peekType(2, p) === 'COLON')) { @@ -289,7 +289,7 @@ function selection(p) { val, }; } else { - const val = value(p); + const val = value(p, config); return { type: 'SELECTION', negate, |