Fixed scan with skip (#2357)
* Fixed bad test for scan The previous test didn't catch the fact that the accumulator had been broke, it's value became the special value `SKIP`. * Fixed Stream.scan() to accept SKIP value * Update stream/stream.js Dropped unnecessary ternary as suggested by @isiahmeadows Co-Authored-By: gamb <adam@gamb.co>
This commit is contained in:
parent
65e2561c55
commit
23fe0a5ab1
2 changed files with 7 additions and 4 deletions
|
|
@ -113,8 +113,9 @@ function merge(streams) {
|
|||
|
||||
function scan(fn, acc, origin) {
|
||||
var stream = origin.map(function(v) {
|
||||
acc = fn(acc, v)
|
||||
return acc
|
||||
var next = fn(acc, v)
|
||||
if (next !== Stream.SKIP) acc = next
|
||||
return next
|
||||
})
|
||||
stream(acc)
|
||||
return stream
|
||||
|
|
|
|||
|
|
@ -51,15 +51,17 @@ o.spec("scan", function() {
|
|||
action(7)
|
||||
action("11")
|
||||
action(undefined)
|
||||
action({a: 1})
|
||||
action({a: 1})
|
||||
action(8) // assures we didn't break the accumulator
|
||||
|
||||
result = child()
|
||||
|
||||
// check we got the expect result
|
||||
o(result[0]).equals(7)
|
||||
o(result[1]).equals(8)
|
||||
|
||||
// check child received minimum # of updates
|
||||
o(count).equals(2)
|
||||
o(count).equals(3)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue