summaryrefslogtreecommitdiff
path: root/lib/mapValuesLimit.js
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2017-04-02 15:23:08 -0700
committerGitHub <noreply@github.com>2017-04-02 15:23:08 -0700
commit49119a895d64991375d1a7b82b3a4d71e3ec8681 (patch)
tree6eb966f6115913e2820e173d2b5ddaa58feb04ac /lib/mapValuesLimit.js
parent66b3c727762e4bf4909e6d8c5e6312810b384204 (diff)
parent8faed87d71496776c7100dc29f2a8e294261c820 (diff)
downloadasync-49119a895d64991375d1a7b82b3a4d71e3ec8681.tar.gz
Merge pull request #1390 from caolan/async-fn-support
`async` function support
Diffstat (limited to 'lib/mapValuesLimit.js')
-rw-r--r--lib/mapValuesLimit.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/mapValuesLimit.js b/lib/mapValuesLimit.js
index 6c9fe06..c6e020d 100644
--- a/lib/mapValuesLimit.js
+++ b/lib/mapValuesLimit.js
@@ -2,6 +2,7 @@ import eachOfLimit from './eachOfLimit';
import noop from 'lodash/noop';
import once from './internal/once';
+import wrapAsync from './internal/wrapAsync';
/**
* The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
@@ -15,10 +16,10 @@ import once from './internal/once';
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. `result` is a new object consisting
* of each key from `obj`, with each transformed value on the right-hand side.
@@ -27,8 +28,9 @@ import once from './internal/once';
export default function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback || noop);
var newObj = {};
+ var _iteratee = wrapAsync(iteratee)
eachOfLimit(obj, limit, function(val, key, next) {
- iteratee(val, key, function (err, result) {
+ _iteratee(val, key, function (err, result) {
if (err) return next(err);
newObj[key] = result;
next();