3 Object.defineProperty(exports, "__esModule", {
6 exports.default = mapValuesLimit;
8 var _eachOfLimit = require('./eachOfLimit');
10 var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
12 var _noop = require('lodash/noop');
14 var _noop2 = _interopRequireDefault(_noop);
16 var _once = require('./internal/once');
18 var _once2 = _interopRequireDefault(_once);
20 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
26 * @name mapValuesLimit
28 * @memberOf module:Collections
30 * @see [async.mapValues]{@link module:Collections.mapValues}
31 * @category Collection
32 * @param {Object} obj - A collection to iterate over.
33 * @param {number} limit - The maximum number of async operations at a time.
34 * @param {Function} iteratee - A function to apply to each value in `obj`.
35 * The iteratee is passed a `callback(err, transformed)` which must be called
36 * once it has completed with an error (which can be `null`) and a
37 * transformed value. Invoked with (value, key, callback).
38 * @param {Function} [callback] - A callback which is called when all `iteratee`
39 * functions have finished, or an error occurs. `result` is a new object consisting
40 * of each key from `obj`, with each transformed value on the right-hand side.
41 * Invoked with (err, result).
43 function mapValuesLimit(obj, limit, iteratee, callback) {
44 callback = (0, _once2.default)(callback || _noop2.default);
46 (0, _eachOfLimit2.default)(obj, limit, function (val, key, next) {
47 iteratee(val, key, function (err, result) {
48 if (err) return next(err);
53 callback(err, newObj);
56 module.exports = exports['default'];