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:
Adam Gamble 2019-01-10 04:10:02 +00:00 committed by Isiah Meadows
parent 65e2561c55
commit 23fe0a5ab1
2 changed files with 7 additions and 4 deletions

View file

@ -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