How to use bach - 4 common examples

To help you get started, we’ve selected a few bach examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VaJoy / BlogDemo2 / 170201 / undertaker-master / lib / parallel.js View on Github external
function parallel() {
  var create = this._settle ? bach.settleParallel : bach.parallel;
  //通过参数获取存在寄存器(registry)中的 taskFunctions(数组形式)
  var args = normalizeArgs(this._registry, arguments);
  //新增一个扩展对象,用于后续给 taskFunction 加上生命周期
  var extensions = createExtensions(this);
  //将 taskFunctions 里的每一个 taskFunction 加上生命周期,且异步化taskFunction,安排它们并发执行(调用fn的时候)
  var fn = create(args, extensions);

  fn.displayName = '';

  //设置初步 metadata,方便外层 this.task 接口获取依赖关系
  metadata.set(fn, {
    name: fn.displayName,
    branch: true,  //表示当前 task 是被依赖的(parallel)任务
    tree: {
      label: fn.displayName,
      type: 'function',
github gulpjs / undertaker / lib / parallel.js View on Github external
function parallel() {
  var create = this._settle ? bach.settleParallel : bach.parallel;

  var args = normalizeArgs(this._registry, arguments);
  var extensions = createExtensions(this);
  var fn = create(args, extensions);
  var name = '';

  metadata.set(fn, {
    name: name,
    branch: true,
    tree: {
      label: name,
      type: 'function',
      branch: true,
      nodes: buildTree(args),
    },
  });
github micahlmartin / nuts / gulpfile.js View on Github external
gulp.task('default', ['clean'], function(cb) {
  bach.series(styles, scripts, images, fonts)(function(err) {
    if(err) {
      handleErrors(err);
    } else {
      return cb();
    }
  })
})
github cloudflare / cloudflare-gcp / cli / cmds / setEnv.js View on Github external
}
    ]
    setTimeout(function () {
      try {
        vinyl.src(`templates/*.yml`)
          .pipe(replace(patterns))
          .pipe(vinyl.dest(`dist`))
      } catch (e) {
        err(e)
      } finally {
        cb(null, 5)
      }
    }, 1000)
  }

  return bach.settleSeries(fn1, fn2, fn3, fn4)()
}

bach

Compose your async functions with elegance.

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis