1.1.2 • Published 7 years ago

pull-combine-latest v1.1.2

Weekly downloads
107
License
ISC
Repository
github
Last release
7 years ago

pull combine latest Build Status

Combine the latest values from many streams. The algorithm waits until every stream has emitted a value, then emits a new array whenever one of the streams has more data.

install

$ npm install pull-combine-latest

example

var S = require('pull-stream')
var combineLatest = require('pull-combine-latest')

S(
    // pass an array of streams
    combineLatest([S.values([1,2,3]), S.values(['a','b','c'])]),
    S.log()
)

S(
    // or pass streams as arguments
    combineLatest(S.values([1,2,3]), S.values(['a','b','c'])),
    S.log()
)

/*
output:

    [1,'a']
    [2,'a']
    [2,'b']
    [3,'b']
    [3,'c']

*/


// new data is emitted as soon as it is received, so sync data will always
// be emitted before async data
S(
    combineLatest(S.values([1,2,3]), asyncValues(['a','b','c'])),
    S.log()
)
/*
    [1,'a']
    [2,'a']
    [3,'a']
    [3,'b']
    [3,'c']
*/


// object map
S(
    combineLatest({
        a: S.values([1,2,3]),
        b: S.values([1,2,3])
    }),
    S.log()
)
/*
    { a: 1, b: 1 }
    { a: 2, b: 1 }
    { a: 2, b: 2 }
    { a: 3, b: 2 }
    { a: 3, b: 3 }
*/
1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago