3 Object.defineProperty(exports, "__esModule", {
7 exports.default = function (coll, iteratee, callback) {
8 var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
9 eachOfImplementation(coll, iteratee, callback);
12 var _isArrayLike = require('lodash/isArrayLike');
14 var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
16 var _breakLoop = require('./internal/breakLoop');
18 var _breakLoop2 = _interopRequireDefault(_breakLoop);
20 var _eachOfLimit = require('./eachOfLimit');
22 var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
24 var _doLimit = require('./internal/doLimit');
26 var _doLimit2 = _interopRequireDefault(_doLimit);
28 var _noop = require('lodash/noop');
30 var _noop2 = _interopRequireDefault(_noop);
32 var _once = require('./internal/once');
34 var _once2 = _interopRequireDefault(_once);
36 var _onlyOnce = require('./internal/onlyOnce');
38 var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
40 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42 // eachOf implementation optimized for array-likes
43 function eachOfArrayLike(coll, iteratee, callback) {
44 callback = (0, _once2.default)(callback || _noop2.default);
52 function iteratorCallback(err, value) {
55 } else if (++completed === length || value === _breakLoop2.default) {
60 for (; index < length; index++) {
61 iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
65 // a generic version of eachOf which can handle array, object, and iterator cases.
66 var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
69 * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
74 * @memberOf module:Collections
77 * @category Collection
78 * @see [async.each]{@link module:Collections.each}
79 * @param {Array|Iterable|Object} coll - A collection to iterate over.
80 * @param {Function} iteratee - A function to apply to each
81 * item in `coll`. The `key` is the item's key, or index in the case of an
82 * array. The iteratee is passed a `callback(err)` which must be called once it
83 * has completed. If no error has occurred, the callback should be run without
84 * arguments or with an explicit `null` argument. Invoked with
85 * (item, key, callback).
86 * @param {Function} [callback] - A callback which is called when all
87 * `iteratee` functions have finished, or an error occurs. Invoked with (err).
90 * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
93 * async.forEachOf(obj, function (value, key, callback) {
94 * fs.readFile(__dirname + value, "utf8", function (err, data) {
95 * if (err) return callback(err);
97 * configs[key] = JSON.parse(data);
103 * }, function (err) {
104 * if (err) console.error(err.message);
105 * // configs is now a map of JSON data
106 * doSomethingWith(configs);
109 module.exports = exports['default'];