JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2881
  • Score
    100M100P100Q116071F
  • License KINDLY

Call functions in parallel and store the results.

Package Exports

  • same-time

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 (same-time) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

same-time Donate now

Call functions in parallel and store the results.

If you want to run async functions synchronously, check out one-by-one.

Installation

$ npm i same-time

Example

// Dependencies
var SameTime = require("same-time");

// Run functions same time and output the results
SameTime([
    function (cb) {
        setTimeout(function() {
            cb(null, "Something async")
        }, 3000);
    }
  , function (cb) {
        setTimeout(function() {
            cb(new Error("An error."))
        }, 500);
    }
  , function (cb) {
        setTimeout(function() {
            cb(null, null, 42)
        }, 2000);
    }
], function (err, data, something) {
    console.log(err, data, something);
    // After 3 seconds
    // [ null, [Error: An error.], null ] [ 'Something async', , null ] [ , , 42 ]
});

Documentation

SameTime(arr, cb)

Calls functions in parallel and stores the results.

Params

  • Array arr: An array of functions getting the callback parameter in the first argument.
  • Function cb: The callback function called with:
  • first parameter: null if there were no errors or an array containing the error values
  • 1 ... n parameters: arrays containing the callback results

Return

  • SameTime The SameTime function.

How to contribute

Have an idea? Found a bug? See how to contribute.

License

KINDLY © Ionică Bizău–The LICENSE file contains a copy of the license.