Sha256: 4c6f8bc46dd769183c36ac6da52bab44eca0e7fc68a86a111749ad65248ba5bc

Contents?: true

Size: 1.23 KB

Versions: 29

Compression:

Stored size: 1.23 KB

Contents

// async-each MIT license (by Paul Miller from https://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

29 entries across 28 versions & 9 rubygems

Version Path
ilog-0.4.0 node_modules/async-each/index.js
ilog-0.3.3 node_modules/async-each/index.js
jester-data-8.0.0 node_modules/async-each/index.js
ezii-os-5.2.1 node_modules/async-each/index.js
ezii-os-2.0.1 node_modules/async-each/index.js
ezii-os-1.1.0 node_modules/async-each/index.js
ezii-os-1.0.0 node_modules/async-each/index.js
ezii-os-0.0.0.1.0 node_modules/async-each/index.js
ezii-os-0.0.0.0.1 node_modules/async-each/index.js