Newton's Preposterous Miscalculation
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    merge-streampublic

    merge-stream

    Merge (interleave) a bunch of streams.

    build status

    Synopsis

    var stream1 = new Stream();
    var stream2 = new Stream();
     
    var merged = mergeStream(stream1, stream2);
     
    var stream3 = new Stream();
    merged.add(stream3);
    merged.isEmpty();
    //=> false

    Description

    This is adapted from event-stream separated into a new module, using Streams3.

    API

    mergeStream

    Type: function

    Merges an arbitrary number of streams. Returns a merged stream.

    merged.add

    A method to dynamically add more sources to the stream. The argument supplied to add can be either a source or an array of sources.

    merged.isEmpty

    A method that tells you if the merged stream is empty.

    When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task.

    So, we could do something like this:

    stream = require('merge-stream')();
    // Something like a loop to add some streams to the merge stream
    // stream.add(streamA);
    // stream.add(streamB);
    return stream.isEmpty() ? null : stream;

    License

    MIT

    Keywords

    none

    install

    npm i merge-stream

    Downloadsweekly downloads

    1,457,026

    version

    1.0.1

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar
    • avatar
    • avatar