Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed scan with skip #2357

Merged
merged 3 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions stream/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
acc = next === Stream.SKIP ? acc : next
return next
})
stream(acc)
return stream
Expand Down
6 changes: 4 additions & 2 deletions stream/tests/test-scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

})