From ca145108a440b080c17ca095214345ebe802cb67 Mon Sep 17 00:00:00 2001 From: miguel76 Date: Sun, 15 May 2016 18:51:50 -0300 Subject: [PATCH] Expose Parse Tree Expose two new functions (parse and compileParsed) for each step of the compile process. So that a user of the library may, if needed, transform the parse tree before translating and compiling it into a function. --- lib/jspath.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/jspath.js b/lib/jspath.js index adb173b..7dc1749 100644 --- a/lib/jspath.js +++ b/lib/jspath.js @@ -1267,7 +1267,11 @@ var translate = (function() { })(); function compile(path) { - return Function('data,subst', translate(parse(path))); + return compileParsed(parse(path)); +} + +function compileParsed(parseTree) { + return Function('data,subst', translate(parseTree)); } var cache = {}, @@ -1314,6 +1318,8 @@ decl.params = function(_params) { } }; +decl.parse = parse; +decl.compileParsed = compileParsed; decl.compile = compile; decl.apply = decl;