add stream folder with scan and scan-merge
This commit is contained in:
parent
db956d7194
commit
db445a899d
4 changed files with 147 additions and 0 deletions
14
stream/scan.js
Normal file
14
stream/scan.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//! adapted for mithril from flyd https://github.com/paldepind/flyd
|
||||
'use strict'
|
||||
|
||||
var combine = require('../stream').combine
|
||||
|
||||
module.exports = function (reducer, seed, stream) {
|
||||
var newStream = combine(function (s) {
|
||||
return seed = reducer(seed, s._state.value)
|
||||
}, [stream])
|
||||
|
||||
if (newStream._state.state === 0) newStream(seed)
|
||||
|
||||
return newStream
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue