diff --git a/jsonata.d.ts b/jsonata.d.ts index 257aac0..0422e22 100644 --- a/jsonata.d.ts +++ b/jsonata.d.ts @@ -31,8 +31,8 @@ declare namespace jsonata { } interface Environment { - bind(name: string, value: any): void; - lookup(name: string): any; + bind(name: string | symbol, value: any): void; + lookup(name: string | symbol): any; readonly timestamp: Date; readonly async: boolean; } diff --git a/src/jsonata.js b/src/jsonata.js index b7dfad5..19e7964 100644 --- a/src/jsonata.js +++ b/src/jsonata.js @@ -50,7 +50,7 @@ var jsonata = (function() { async function evaluate(expr, input, environment) { var result; - var entryCallback = environment.lookup('__evaluate_entry'); + var entryCallback = environment.lookup(Symbol.for('jsonata.__evaluate_entry')); if(entryCallback) { await entryCallback(expr, input, environment); } @@ -124,7 +124,7 @@ var jsonata = (function() { result = await evaluateGroupExpression(expr.group, result, environment); } - var exitCallback = environment.lookup('__evaluate_exit'); + var exitCallback = environment.lookup(Symbol.for('jsonata.__evaluate_exit')); if(exitCallback) { await exitCallback(expr, input, environment, result); } diff --git a/test/implementation-tests.js b/test/implementation-tests.js index 6df7e67..1e162f6 100644 --- a/test/implementation-tests.js +++ b/test/implementation-tests.js @@ -1057,11 +1057,11 @@ function timeboxExpression(expr, timeout, maxDepth) { }; // register callbacks - expr.assign("__evaluate_entry", function() { + expr.assign(Symbol.for('jsonata.__evaluate_entry'), function() { depth++; checkRunnaway(); }); - expr.assign("__evaluate_exit", function() { + expr.assign(Symbol.for('jsonata.__evaluate_exit'), function() { depth--; checkRunnaway(); }); diff --git a/test/run-test-suite.js b/test/run-test-suite.js index d851fbf..60beee0 100644 --- a/test/run-test-suite.js +++ b/test/run-test-suite.js @@ -178,12 +178,12 @@ function timeboxExpression(expr, timeout, maxDepth) { }; // register callbacks - expr.assign("__evaluate_entry", function(expr, input, env) { + expr.assign(Symbol.for('jsonata.__evaluate_entry'), function(expr, input, env) { if (env.isParallelCall) return; depth++; checkRunnaway(); }); - expr.assign("__evaluate_exit", function(expr, input, env) { + expr.assign(Symbol.for('jsonata.__evaluate_exit'), function(expr, input, env) { if (env.isParallelCall) return; depth--; checkRunnaway();