mapValues.js
 1  'use strict';
 2  
 3  Object.defineProperty(exports, "__esModule", {
 4    value: true
 5  });
 6  exports.default = mapValues;
 7  
 8  var _mapValuesLimit = require('./mapValuesLimit');
 9  
10  var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
11  
12  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13  
14  /**
15   * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
16   *
17   * Produces a new Object by mapping each value of `obj` through the `iteratee`
18   * function. The `iteratee` is called each `value` and `key` from `obj` and a
19   * callback for when it has finished processing. Each of these callbacks takes
20   * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
21   * passes an error to its callback, the main `callback` (for the `mapValues`
22   * function) is immediately called with the error.
23   *
24   * Note, the order of the keys in the result is not guaranteed.  The keys will
25   * be roughly in the order they complete, (but this is very engine-specific)
26   *
27   * @name mapValues
28   * @static
29   * @memberOf module:Collections
30   * @method
31   * @category Collection
32   * @param {Object} obj - A collection to iterate over.
33   * @param {AsyncFunction} iteratee - A function to apply to each value and key
34   * in `coll`.
35   * The iteratee should complete with the transformed value as its result.
36   * Invoked with (value, key, callback).
37   * @param {Function} [callback] - A callback which is called when all `iteratee`
38   * functions have finished, or an error occurs. `result` is a new object consisting
39   * of each key from `obj`, with each transformed value on the right-hand side.
40   * Invoked with (err, result).
41   * @returns {Promise} a promise, if no callback is passed
42   * @example
43   *
44   * async.mapValues({
45   *     f1: 'file1',
46   *     f2: 'file2',
47   *     f3: 'file3'
48   * }, function (file, key, callback) {
49   *   fs.stat(file, callback);
50   * }, function(err, result) {
51   *     // result is now a map of stats for each file, e.g.
52   *     // {
53   *     //     f1: [stats for file1],
54   *     //     f2: [stats for file2],
55   *     //     f3: [stats for file3]
56   *     // }
57   * });
58   */
59  function mapValues(obj, iteratee, callback) {
60    return (0, _mapValuesLimit2.default)(obj, Infinity, iteratee, callback);
61  }
62  module.exports = exports['default'];