How to use the neo-async.whilst function in neo-async

To help you get started, we’ve selected a few neo-async 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 msioda / BioLockJ / web_app / node_modules / handlebars / lib / precompiler.js View on Github external
function loadFiles(opts, callback) {
  // Build file extension pattern
  let extension = (opts.extension || 'handlebars').replace(/[\\^$*+?.():=!|{}\-[\]]/g, function(arg) { return '\\' + arg; });
  extension = new RegExp('\\.' + extension + '$');

  let ret = [],
      queue = (opts.files || []).map((template) => ({template, root: opts.root}));
  Async.whilst(() => queue.length, function(callback) {
    let {template: path, root} = queue.shift();

    fs.stat(path, function(err, stat) {
      if (err) {
        return callback(new Handlebars.Exception(`Unable to open template file "${path}"`));
      }

      if (stat.isDirectory()) {
        opts.hasDirectory = true;

        fs.readdir(path, function(err, children) {
          /* istanbul ignore next : Race condition that being too lazy to test */
          if (err) {
            return callback(err);
          }
          children.forEach(function(file) {
github publiclab / Leaflet.DistortableImage / node_modules / handlebars / lib / precompiler.js View on Github external
function loadFiles(opts, callback) {
  // Build file extension pattern
  let extension = (opts.extension || 'handlebars').replace(/[\\^$*+?.():=!|{}\-[\]]/g, function(arg) { return '\\' + arg; });
  extension = new RegExp('\\.' + extension + '$');

  let ret = [],
      queue = (opts.files || []).map((template) => ({template, root: opts.root}));
  Async.whilst(() => queue.length, function(callback) {
    let {template: path, root} = queue.shift();

    fs.stat(path, function(err, stat) {
      if (err) {
        return callback(new Handlebars.Exception(`Unable to open template file "${path}"`));
      }

      if (stat.isDirectory()) {
        opts.hasDirectory = true;

        fs.readdir(path, function(err, children) {
          /* istanbul ignore next : Race condition that being too lazy to test */
          if (err) {
            return callback(err);
          }
          children.forEach(function(file) {
github wycats / handlebars.js / lib / precompiler.js View on Github external
function loadFiles(opts, callback) {
  // Build file extension pattern
  let extension = (opts.extension || 'handlebars').replace(
    /[\\^$*+?.():=!|{}\-[\]]/g,
    function(arg) {
      return '\\' + arg;
    }
  );
  extension = new RegExp('\\.' + extension + '$');

  let ret = [],
    queue = (opts.files || []).map(template => ({ template, root: opts.root }));
  Async.whilst(
    () => queue.length,
    function(callback) {
      let { template: path, root } = queue.shift();

      fs.stat(path, function(err, stat) {
        if (err) {
          return callback(
            new Handlebars.Exception(`Unable to open template file "${path}"`)
          );
        }

        if (stat.isDirectory()) {
          opts.hasDirectory = true;

          fs.readdir(path, function(err, children) {
            /* istanbul ignore next : Race condition that being too lazy to test */
github linitix / nzero-push / lib / common / requests_manager.js View on Github external
RequestsManager.prototype.devices = function (page, perPage, callback) {
  var self     = this;
  var finished = false;
  var data     = [];

  if ( typeof self.authenticated === "boolean" && !self.authenticated )
    return callback(new UnauthorizedAccessError("Resource access denied"));

  async.whilst(
    function () { return !finished; },
    function (next) {
      var requestOptions = {
        url    : BASE_URL + "/devices?auth_token=" + self.authToken + "&page=" + page + "&per_page=" + perPage,
        method : "GET",
        headers: BASE_HEADERS,
        json   : true
      };

      debug(requestOptions);

      executeRequest(requestOptions, function (err, body, headers) {
        if ( err )
          return next(err);

        getDeviceQuotaFromResponseHeaders(headers, self);