run-parallel

中文文档
1.2.0发布于 2021/02/10MITCommonJS近 30 天下载 5.1亿

Run an array of functions in parallel

原始使用文档
文档目录5 节
  1. Run an array of functions in parallel
  2. install
  3. usage
  4. see also
  5. license

run-parallel travis npm downloads javascript style guide

Run an array of functions in parallel

parallel Sauce Test Status

install

npm install run-parallel

usage

parallel(tasks, [callback])

Run the tasks array of functions in parallel, without waiting until the previous function has completed. If any of the functions pass an error to its callback, the main callback is immediately called with the value of the error. Once the tasks have completed, the results are passed to the final callback as an array.

It is also possible to use an object instead of an array. Each property will be run as a function and the results will be passed to the final callback as an object instead of an array. This can be a more readable way of handling the results.

arguments
  • tasks - An array or object containing functions to run. Each function is passed a callback(err, result) which it must call on completion with an error err (which can be null) and an optional result value.
  • callback(err, results) - An optional callback to run once all the functions have completed. This function gets a results array (or object) containing all the result arguments passed to the task callbacks.
example
var parallel = require('run-parallel')

parallel([
  function (callback) {
    setTimeout(function () {
      callback(null, 'one')
    }, 200)
  },
  function (callback) {
    setTimeout(function () {
      callback(null, 'two')
    }, 100)
  }
],
// optional callback
function (err, results) {
  // the results array will equal ['one','two'] even though
  // the second function had a shorter timeout.
})

This module is basically equavalent to async.parallel, but it's handy to just have the one function you need instead of the kitchen sink. Modularity! Especially handy if you're serving to the browser and need to reduce your javascript bundle size.

Works great in the browser with browserify!

see also

license

MIT. Copyright (c) Feross Aboukhadijeh.

版本与发布记录

run-parallel 共发布 17 个版本,首次发布于 2014/04/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.0latest2021/02/105 年前
1.1.102020/10/276 年前
1.1.92018/04/268 年前
1.1.82018/03/178 年前
1.1.72018/02/148 年前
1.1.62016/03/2910 年前

关于 run-parallel 的常见问题

run-parallel 是什么?

Run an array of functions in parallel

如何安装 run-parallel?

在项目目录运行 npm install run-parallel,或使用 pnpm add / yarn add / bun add。

run-parallel 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/run-parallel 是否存在。

run-parallel 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

run-parallel 可以商用吗?

run-parallel 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

run-parallel 的下载量有多少?

根据 npm 官方下载统计,run-parallel 在 2026/10/05 – 2026/11/03 这 30 天内被下载 507,548,922 次,日均约 16,918,297 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

run-parallel 还在维护吗?

最新版本 1.2.0 发布于 2021/02/10(5 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2014/04/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。