Sha256: cebab026c11c68e585fdf9624d49f9a6014ae711aef312406b01b6f314fcdcad

Contents?: true

Size: 1.23 KB

Versions: 106

Compression:

Stored size: 1.23 KB

Contents

// async-each MIT license (by Paul Miller from http://paulmillr.com).
(function(globals) {
  'use strict';
  var each = function(items, next, callback) {
    if (!Array.isArray(items)) throw new TypeError('each() expects array as first argument');
    if (typeof next !== 'function') throw new TypeError('each() expects function as second argument');
    if (typeof callback !== 'function') callback = Function.prototype; // no-op

    if (items.length === 0) return callback(undefined, items);

    var transformed = new Array(items.length);
    var count = 0;
    var returned = false;

    items.forEach(function(item, index) {
      next(item, function(error, transformedItem) {
        if (returned) return;
        if (error) {
          returned = true;
          return callback(error);
        }
        transformed[index] = transformedItem;
        count += 1;
        if (count === items.length) return callback(undefined, transformed);
      });
    });
  };

  if (typeof define !== 'undefined' && define.amd) {
    define([], function() {
      return each;
    }); // RequireJS
  } else if (typeof module !== 'undefined' && module.exports) {
    module.exports = each; // CommonJS
  } else {
    globals.asyncEach = each; // <script>
  }
})(this);

Version data entries

106 entries across 106 versions & 15 rubygems

Version Path
blsk-sevcore-0.0.2 blsk_old/bluesky-doc/bluesky-doc/node_modules/async-each/index.js
optimacms-0.4.3 spec/dummy/node_modules/async-each/index.js
optimacms-0.4.2 spec/dummy/node_modules/async-each/index.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/async-each/index.js
lux_assets-0.2.11 ./node_modules/async-each/index.js
lux_assets-0.2.9 ./node_modules/async-each/index.js
lux_assets-0.2.4 ./node_modules/async-each/index.js
lux_assets-0.2.2 ./node_modules/async-each/index.js
lux_assets-0.2.1 ./node_modules/async-each/index.js
locomotivecms-3.4.0 app/javascript/node_modules/async-each/index.js
cortex-0.1.3 spec/dummy/node_modules/async-each/index.js
dragonfly_puppeteer-0.1.0 node_modules/async-each/index.js
affiliator-0.2.1 node_modules/async-each/index.js
lanes-0.8.0 node_modules/async-each/index.js
brwy_rails-0.0.6 test/dummy/node_modules/async-each/index.js
brwy_rails-0.0.5 test/dummy/node_modules/async-each/index.js
blackboard-3.1.9 lib/site_template/node_modules/async-each/index.js
brwy_rails-0.0.4 test/dummy/node_modules/async-each/index.js
brwy_rails-0.0.3 test/dummy/node_modules/async-each/index.js
brwy_rails-0.0.2 test/dummy/node_modules/async-each/index.js