streams-to-promise

    1.0.2 • Public • Published

    streams-to-promise

    License Build status

    Promises conclusion of multiple streams (readable or writable)

    Based on Ben Drucker's stream-to-promise, it expands the functionality for multiple streams.

    Installation

    npm install streams-to-promise
    
    var all = require('streams-to-promise');
    var { all, race } = require('streams-to-promise');

    Examples

    Promising conclusion of all streams
    var promiseAllStreams = require('streams-to-promise');
     
    var stream1 = ...;
    var stream2 = ...;
    ...
    var streamN = ...;
     
    promiseAllStreams(stream1, stream2, ..., streamN).then(function (results) {
        // results[0] -> streamed data from stream1
        // results[1] -> streamed data from stream2
        // ...
        // results[N-1] -> streamed data from streamN
    });
    Racing conclusion of streams
    var raceStreams = require('streams-to-promise').race;
     
    var stream1 = ...;
    var stream2 = ...;
    ...
    var streamN = ...;
     
    raceStreams(stream1, stream2, ..., streamN).then(function (result) {
        // result -> streamed data from stream that concluded first
    });
    Usage with Gulp
    ...
    var { all, race } = require('streams-to-promise');
     
    gulp.task('mytask', () => {
     
        ...
     
        // Performs stream operations in parallel and promises its conclusion
        //
        return all(
     
            gulp.src(...)
                .pipe(...)
                .pipe(...),
     
            gulp.src(...)
                .pipe(...)
                .pipe(...),
     
            ...
     
        );
     
    });

    API

    all([s1[, s2[, ...[, sN]]]])
    var all = require('streams-to-promise');
    var all = require('streams-to-promise').all;
    race([s1[, s2[, ...[, sN]]]])
    var race = require('streams-to-promise').race;

    License

    MIT

    Install

    npm i streams-to-promise

    DownloadsWeekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • jd342