Skip to content

Commit 63b4ffc

Browse files
andrew-colemanmattbaileyuk
authored andcommitted
rewrite array flattening to avoid RangeError
Signed-off-by: andrew-coleman <[email protected]>
1 parent 66ecc0b commit 63b4ffc

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/functions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ const functions = (() => {
16711671
var res = lookup(input[ii], key);
16721672
if (typeof res !== 'undefined') {
16731673
if (Array.isArray(res)) {
1674-
result.push(...res);
1674+
res.forEach(val => result.push(val));
16751675
} else {
16761676
result.push(res);
16771677
}

src/jsonata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ var jsonata = (function() {
283283
resultSequence.push(res);
284284
} else {
285285
// res is a sequence - flatten it into the parent sequence
286-
Array.prototype.push.apply(resultSequence, res);
286+
res.forEach(val => resultSequence.push(val));
287287
}
288288
});
289289
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"expr": "( $data := { 'number': [1..2e5].$string() }; $values := $data.number; $count($values) )",
4+
"data": null,
5+
"result": 200000,
6+
"timelimit": 10000,
7+
"depth": 10
8+
},
9+
{
10+
"expr": "( $data := { 'number': [1..2e5].$string() }; $values := $lookup($data, 'number'); $count($values) )",
11+
"data": null,
12+
"result": 200000,
13+
"timelimit": 10000,
14+
"depth": 10
15+
}
16+
]

0 commit comments

Comments
 (0)