From 611a4424b4490592fd037279f65e22630e66ffd4 Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Wed, 1 Jun 2016 13:04:09 -0700 Subject: simplify index tracking --- lib/internal/map.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'lib/internal/map.js') diff --git a/lib/internal/map.js b/lib/internal/map.js index b587f59..2c2a750 100644 --- a/lib/internal/map.js +++ b/lib/internal/map.js @@ -1,23 +1,16 @@ -import isArrayLike from 'lodash/isArrayLike'; -import getIterator from './getIterator'; import noop from 'lodash/noop'; -import okeys from 'lodash/keys'; -import indexOf from 'lodash/_baseIndexOf'; import once from './once'; export default function _asyncMap(eachfn, arr, iteratee, callback) { callback = once(callback || noop); arr = arr || []; var results = []; - var keys; - if (!isArrayLike(arr) && !getIterator(arr)) { - keys = okeys(arr); - } + var counter = 0; - eachfn(arr, function (value, index, callback) { + eachfn(arr, function (value, _, callback) { + var index = counter++; iteratee(value, function (err, v) { - var idx = keys ? indexOf(keys, index, 0) : index; - results[idx] = v; + results[index] = v; callback(err); }); }, function (err) { -- cgit v1.2.1