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
smock-0.1.265 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.264 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.263 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.262 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.261 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.260 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.259 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.258 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.256 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.255 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.254 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.253 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.252 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.251 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.250 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
smock-0.1.249 node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/async-each/index.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/chokidar/node_modules/async-each/index.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/chokidar/node_modules/async-each/index.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/chokidar/node_modules/async-each/index.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/chokidar/node_modules/async-each/index.js