2.0.1 • Published 8 years ago

stream-combine v2.0.1

Weekly downloads
26
License
ISC
Repository
github
Last release
8 years ago

stream-combine

Merges chronological time-based streams.

Usage

I.e. when you have 3 time serie streams, with common document key _id for unix time stamp.

async.map [
  "time-series-1"
  "time-series-2"
  "time-series-3"
], (serie, cb) ->
  db.collection serie, (error, collection) ->
    return cb error if error
    
    stream = collection
      .find _id: $gt: 12
      .sort _id: 1
      .stream()
    
    cb null, stream
, (error, streams) ->
  (new StreamCombine streams, "_id").pipe someCSVStream

Or in flowing mode, with example of output object structure:

(new StreamCombine streams, "_id").on "data", (data) ->
  console.log data
  # emits objects like
  # {
  #   indexes: [0, 2] 
  #   data:    [ { _id: 6, some-data-from-time-series-1 }, { _id: 6, some-data-from-time-series-3 } ]
  # }
  # ...

where:

_id is the common time stamp of the next object in chronological order

indexes is the indexes of the streams that have the current time in common

data is the actual data of the common time step

2.0.2

6 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago