From 19ecb59493f2d58a0330b4cd9fdfe0072e18dee7 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 28 Sep 2018 21:38:46 +0300 Subject: [PATCH] added context to getter... Signed-off-by: Alex A. Naanou --- walk.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/walk.js b/walk.js index b942c77..356fccf 100644 --- a/walk.js +++ b/walk.js @@ -130,6 +130,7 @@ // XXX might be a good idea to move this into it's own module... // generic-walk might be a good name... var walk = function(get, state, ...nodes){ + var context = {} // this is used to break out of the recursion... // NOTE: this can leak out but we only care about it's identity thus // no damage can be done... @@ -141,7 +142,7 @@ var walk = function(get, state, ...nodes){ // results... var _get = function(node){ var next = [] - res = get( + res = get.call(context, res, node, // breadth first step...