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
optimacms-0.1.61 spec/dummy/node_modules/async-each/index.js
disco_app-0.18.0 test/dummy/node_modules/async-each/index.js
disco_app-0.18.2 test/dummy/node_modules/async-each/index.js
disco_app-0.16.1 test/dummy/node_modules/async-each/index.js
disco_app-0.15.2 test/dummy/node_modules/async-each/index.js
disco_app-0.18.4 test/dummy/node_modules/async-each/index.js
disco_app-0.18.1 test/dummy/node_modules/async-each/index.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/async-each/index.js
disco_app-0.14.0 test/dummy/node_modules/async-each/index.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/async-each/index.js
tang-0.2.1 spec/tang_app/node_modules/async-each/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/async-each/index.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/async-each/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/async-each/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/async-each/index.js
tang-0.2.0 spec/tang_app/node_modules/async-each/index.js
tang-0.1.0 spec/tang_app/node_modules/async-each/index.js
tang-0.0.9 spec/tang_app/node_modules/async-each/index.js
enju_library-0.3.8 spec/dummy/node_modules/async-each/index.js
ilog-0.4.1 node_modules/async-each/index.js