Skip to content

Commit 05c148a

Browse files
andrew-colemanmattbaileyuk
authored andcommitted
$each should not result in undefined values in the result object
1 parent 68201a7 commit 05c148a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/functions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,10 @@ const functions = (() => {
16301630
for (var key in obj) {
16311631
var func_args = hofFuncArgs(func, obj[key], key, obj);
16321632
// invoke func
1633-
result.push(yield* func.apply(this, func_args));
1633+
var val = yield* func.apply(this, func_args);
1634+
if(typeof val !== 'undefined') {
1635+
result.push(val);
1636+
}
16341637
}
16351638

16361639
return result;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"expr": "$each(function($v, $k) {$k[$v>2]})",
3+
"data": { "a": 1, "b": 2, "c": 3, "d": 4 },
4+
"bindings": {},
5+
"result": ["c", "d"],
6+
"unordered": true
7+
}

0 commit comments

Comments
 (0)