From e32efa6cc0636bddb6a4ba7da85b6c91b6f38bf8 Mon Sep 17 00:00:00 2001 From: Sergeev Viktor Date: Mon, 26 Jan 2026 02:47:10 +0300 Subject: [PATCH] Issues-767: change the 'each' signature to work with arrays --- src/jsonata.js | 2 +- test/test-suite/groups/function-each/case003.json | 7 +++++++ test/test-suite/groups/function-each/case004.json | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/test-suite/groups/function-each/case003.json create mode 100644 test/test-suite/groups/function-each/case004.json diff --git a/src/jsonata.js b/src/jsonata.js index c21eb1e2..cdf7449c 100644 --- a/src/jsonata.js +++ b/src/jsonata.js @@ -1916,7 +1916,7 @@ var jsonata = (function() { staticFrame.bind('spread', defineFunction(fn.spread, '>')); staticFrame.bind('merge', defineFunction(fn.merge, ':o>')); staticFrame.bind('reverse', defineFunction(fn.reverse, '')); - staticFrame.bind('each', defineFunction(fn.each, '')); + staticFrame.bind('each', defineFunction(fn.each, '<(ao)-f:a>')); staticFrame.bind('error', defineFunction(fn.error, '')); staticFrame.bind('assert', defineFunction(fn.assert, '')); staticFrame.bind('type', defineFunction(fn.type, '')); diff --git a/test/test-suite/groups/function-each/case003.json b/test/test-suite/groups/function-each/case003.json new file mode 100644 index 00000000..28ef1bf1 --- /dev/null +++ b/test/test-suite/groups/function-each/case003.json @@ -0,0 +1,7 @@ +{ + "expr": "$each([123, 321], function($v) {$v})", + "data": {}, + "bindings": {}, + "result": [123, 321], + "unordered": true +} diff --git a/test/test-suite/groups/function-each/case004.json b/test/test-suite/groups/function-each/case004.json new file mode 100644 index 00000000..ffc54350 --- /dev/null +++ b/test/test-suite/groups/function-each/case004.json @@ -0,0 +1,7 @@ +{ + "expr": "[123, 321] ~> $each(?, function($v) {$v})", + "data": {}, + "bindings": {}, + "result": [123, 321], + "unordered": true +}