JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3564
  • Score
    100M100P100Q116022F
  • 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 Support this project

Call functions in parallel and store the results.

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

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.

Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

License

KINDLY © Ionică Bizău