How to use asynckit - 10 common examples

To help you get started, we’ve selected a few asynckit 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 alexindigo / fbbot / test / common.js View on Github external
function iterateSendings(iterator)
{
  asynckit.serial(common.sendings, function(item, type, callback)
  {
    // each item is an array by itself
    asynckit.serial(item, function(test, id, cb)
    {
      // differentiate elements within same type
      iterator(test, type + '-' + id, cb);
    }, callback);

  }, function noop(err){ assert.ifError(err, 'expects all sendings to finish without errors'); });
}
github alexindigo / fbbot / test / common.js View on Github external
asynckit.serial(common.sendings, function(item, type, callback)
  {
    // each item is an array by itself
    asynckit.serial(item, function(test, id, cb)
    {
      // differentiate elements within same type
      iterator(test, type + '-' + id, cb);
    }, callback);

  }, function noop(err){ assert.ifError(err, 'expects all sendings to finish without errors'); });
}
github alexindigo / fbbot / traverse / index.js View on Github external
Traverse.prototype.traverse = function(branch, payload, callback)
{
  // check for optional argument
  if (typeOf(branch) == 'object')
  {
    callback = payload;
    payload  = branch;
    branch   = this.entry;
  }

  // allow it to handle arrays as entry payload
  if (typeOf(payload) == 'array')
  {
    // process all entries in parallel
    // supposedly they are unrelated to each other on this level of details
    asynckit.parallel(payload, this.traverse.bind(this, branch), callback);
    return;
  }

  this.logger.debug({message: 'Traversing payload under branch handle', branch: branch, payload: payload});

  if (typeOf(payload) != 'object')
  {
    this.logger.error({message: 'payload is not an Object', branch: branch, payload: payload});
    callback(new Error('payload <' + branch + '> is not an Object'));
    return;
  }

  // invoke middleware controller with custom context
  this.middleware(this.prefixedBranch(branch), payload, function(error, resolvedPayload)
  {
    var nextStep = this.steps[branch]
github alexindigo / ndash / app / lib / Api.js View on Github external
static getPackageDetails(id, callback) {

    // partially escape package id o_0
    id = id.replace(/\//g, '%2F');

    const endpoints = [this.endpointRegistry, this.endpointPackageDetails];

    asynckit.parallel(endpoints, (endpoint, cb) => {
      this._request(endpoint + id, {
        method: 'GET',
        headers: {
          'Accept': 'application/json'
        }
      },
      function(error, result)
      {
        if (error || (!result.name && !result.analyzedAt)) {
          cb(error || 'unable to fetch package details for [' + id + '] package from [' + endpoint + '] endpoint');
          return;
        }

        cb(null, result);
      });
    }, (error, results) => {
github concur / skipper / node_modules / supertest / node_modules / form-data / lib / form_data.js View on Github external
FormData.prototype.getLength = function(cb) {
  var knownLength = this._overheadLength + this._valueLength;

  if (this._streams.length) {
    knownLength += this._lastBoundary().length;
  }

  if (!this._valuesToMeasure.length) {
    process.nextTick(cb.bind(this, null, knownLength));
    return;
  }

  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
    if (err) {
      cb(err);
      return;
    }

    values.forEach(function(length) {
      knownLength += length;
    });

    cb(null, knownLength);
  });
};
github alexindigo / fbbot / test / common.js View on Github external
function iterateRequests(iterator)
{
  asynckit.serial(common.requests, iterator, function noop(err){ assert.ifError(err, 'expects all requests to finish without errors'); });
}
github form-data / form-data / lib / form_data.js View on Github external
FormData.prototype.getLength = function(cb) {
  var knownLength = this._overheadLength + this._valueLength;

  if (this._streams.length) {
    knownLength += this._lastBoundary().length;
  }

  if (!this._valuesToMeasure.length) {
    process.nextTick(cb.bind(this, null, knownLength));
    return;
  }

  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
    if (err) {
      cb(err);
      return;
    }

    values.forEach(function(length) {
      knownLength += length;
    });

    cb(null, knownLength);
  });
};
github tushgup / heybrandie / messenger-bot / node_modules / form-data / lib / form_data.js View on Github external
FormData.prototype.getLength = function(cb) {
  var knownLength = this._overheadLength + this._valueLength;

  if (this._streams.length) {
    knownLength += this._lastBoundary().length;
  }

  if (!this._valuesToMeasure.length) {
    process.nextTick(cb.bind(this, null, knownLength));
    return;
  }

  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
    if (err) {
      cb(err);
      return;
    }

    values.forEach(function(length) {
      knownLength += length;
    });

    cb(null, knownLength);
  });
};
github Graphite-Docs / graphite / node_modules / bower / lib / node_modules / form-data / lib / form_data.js View on Github external
FormData.prototype.getLength = function(cb) {
  var knownLength = this._overheadLength + this._valueLength;

  if (this._streams.length) {
    knownLength += this._lastBoundary().length;
  }

  if (!this._valuesToMeasure.length) {
    process.nextTick(cb.bind(this, null, knownLength));
    return;
  }

  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
    if (err) {
      cb(err);
      return;
    }

    values.forEach(function(length) {
      knownLength += length;
    });

    cb(null, knownLength);
  });
};
github aermin / ghChat / node_modules / node-sass / node_modules / form-data / lib / form_data.js View on Github external
FormData.prototype.getLength = function(cb) {
  var knownLength = this._overheadLength + this._valueLength;

  if (this._streams.length) {
    knownLength += this._lastBoundary().length;
  }

  if (!this._valuesToMeasure.length) {
    process.nextTick(cb.bind(this, null, knownLength));
    return;
  }

  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
    if (err) {
      cb(err);
      return;
    }

    values.forEach(function(length) {
      knownLength += length;
    });

    cb(null, knownLength);
  });
};

asynckit

Minimal async jobs utility library, with streams support

MIT
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis

Popular asynckit functions