JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1234
  • Score
    100M100P100Q95606F
  • License MIT

Asnyc map that actualy works. Parallel and Series

Package Exports

  • foreign

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (foreign) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

foreign

Asnyc map that actualy works. Parallel, series, cury

Usage

var foreign = require('foreign');

Parallel

var items = [1,2,3];

foreign.parallel(
    function(item, callback){
        somethingAsync(item, callback);
    },
    items,
    function(error, result){

    }
);

Series

var items = [1,2,3];

foreign.series(
    function(item, callback){
        somethingAsync(item, callback);
    },
    items,
    function(error, result){

    }
);

SeriesAll

var items = [1,2,3];

foreign.seriesAll(
    function(item, callback) {
        somethingAsync(item, callback);
    },
    items,
    function(error, result) {
        // 'error' will always be a either array or object of errors
        // 'result' will always be a either array or object of results
        // depending on the type `items` is.
        //
        // NOTE: `error.length` is not a reliable indicator of number of errors
        //
        // All items will be processed in order even if
        // some return errors. `foreign.series` will return
        // on first error

        // example error checking:
        if (error) {
            var itemsThatFailed = Object.keys(error);
        }
    }
);

Multiple return values

var items = [1,2,3];

    foreign.series(
        function(item, callback){
            callback(null, item, 'foo');
        },
        items,
        function(error, results){
            console.log(results); // [[1, 'foo'], [2, 'foo'], [3, 'foo']]
        }
    );