UNPKG

jora

Version:

JavaScript object query engine

31 lines (28 loc) 632 B
'use strict'; function compile(node, ctx) { ctx.put(ctx.buildinFn('filter')); ctx.put('('); ctx.nodeOrCurrent(node.value); ctx.put(',$=>'); ctx.createScope( () => ctx.node(node.query), (sp) => { ctx.put(')'); return '(' + sp + ','; } ); ctx.put(')'); } function walk(node, ctx) { ctx.nodeOrNothing(node.value); ctx.node(node.query); } function stringify(node, ctx) { ctx.nodeOrNothing(node.value); ctx.put('.['); ctx.node(node.query); ctx.put(']'); } exports.compile = compile; exports.stringify = stringify; exports.walk = walk;