Skip to content

Commit

Permalink
$each should not result in undefined values in the result object
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-coleman authored and mattbaileyuk committed Jan 10, 2019
1 parent 68201a7 commit 05c148a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions.js
Expand Up @@ -1630,7 +1630,10 @@ const functions = (() => {
for (var key in obj) {
var func_args = hofFuncArgs(func, obj[key], key, obj);
// invoke func
result.push(yield* func.apply(this, func_args));
var val = yield* func.apply(this, func_args);
if(typeof val !== 'undefined') {
result.push(val);
}
}

return result;
Expand Down
7 changes: 7 additions & 0 deletions test/test-suite/groups/function-each/case002.json
@@ -0,0 +1,7 @@
{
"expr": "$each(function($v, $k) {$k[$v>2]})",
"data": { "a": 1, "b": 2, "c": 3, "d": 4 },
"bindings": {},
"result": ["c", "d"],
"unordered": true
}

0 comments on commit 05c148a

Please sign in to comment.