Works like async.map

@param array
@param iterator
@param done
765448
function asyncMap(array, iterator, done) {
  if (!array || !array.length) {
    return done(null, [])
  }

  var error
    , out = []
    , todo = array.length

  array.forEach(exec)

  function exec(item) {
    process.nextTick(function tick() {
      iterator(item, add)
    })
  }

  function add(err, data) {
    if (error) {
      return
    }
    else if (err) {
      error = true
      return done(err)
    }

    out.push(data)

    if (--todo === 0) {
      done(null, out)
    }
  }
}
630774
function AsyncLoop(iterations, _fn, _successCallback, offset) {
            if (offset === void 0) { offset = 0; }
            this.iterations = iterations;
            this._fn = _fn;
            this._successCallback = _successCallback;
            this.index = offset - 1;
            this._done = false;
        }
1328789
function(obj, iterator, context) {
        if (!obj) return
        else if (obj.forEach) obj.forEach(iterator)
        else if (obj.length == +obj.length) {
            for (var i = 0; i < obj.length; i++) iterator.call(context, obj[i], i)
        } else {
            for (var key in obj) iterator.call(context, obj[key], key)
        }
    }
1093195
function _asyncEverySeries (arr, iterator, callback) {
  if (!arr.length) {
    return callback();
  }

  var completed = 0;
  (function iterate() {
    iterator(arr[completed], function (err) {
      if (err || err === false) {
        callback(err);
        callback = function () {};
      }
      else {
        completed += 1;
        if (completed === arr.length) {
          callback();
        }
        else {
          iterate();
        }
      }
    });
  })();
}
3554
private Iterator<Object> arrayIt(final Object array) {
        return new Iterator<Object>() {
            private int index = 0;
            private final int length = Array.getLength(array);
            @Override
            public boolean hasNext() {
                return this.index < this.length;
            }
            @Override
            public Object next() {
                try {
                    return Array.get(array, this.index++);
                } catch (Throwable t) {
                    throw new NoSuchElementException(t.getMessage());
                }
            }
        };
    }
61915
function iterator(state, tasks, callback)
{
  var keys
    , tasksLeft = tasks.length
    , task      = tasks.shift()
    ;

  if (tasksLeft === 0)
  {
    return callback(null, state);
  }

  // init current task reference
  state._currentTask = {waiters: {}};

  if (typeOf(task) == 'object')
  {
    // update state with new options
    // to make it available for all the subcommands
    if (typeOf(task.options) == 'object')
    {
      state.options = extend(state.options || {}, task.options);

      // no need to process it further
      delete task.options;
    }

    // generate list of properties to update
    keys = Object.keys(task);
  }

  // convert non-array and non-object elements
  // into single element arrays
  if (typeof task != 'object')
  {
    task = [task];
  }

  execute(state, task, keys, function(err, modifiedState)
  {
    // reset current task
    // if it's error and modified state
    // isn't provided, use context
    (modifiedState || state)._currentTask = undefined; // eslint-disable-line no-undefined

    if (err) return callback(err);

    // proceed to the next element
    iterator(modifiedState, tasks, callback);
  });
}
676019
function each(obj, iterator, context) {
    var i;

    if (!obj) {
        return;
    }

    if (obj.forEach) {
        obj.forEach(iterator, context);
    } else if (obj.length !== undefined) {
        i = 0;
        while (i < obj.length) {
            iterator.call(context, obj[i], i, obj);
            i++;
        }
    } else {
        for (i in obj) {
            obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
        }
    }
}
512661
@Override
    public Iterator<T> iterator() {
        Iterator<T> transformed = Iterators.transform(rows.iterator(), row -> {
            T value = mapper.map(row);
            mapper.mappingComplete();
            return value;
        });
        mapper.mappingComplete();
        return transformed;
    }
418080
public <N> CompletableFutureQueue<T, N> thenCombineAsyncFromArray(Function<R, N>[] nextTransformations) {
    CompletableFutureQueue cfq = this;
    for (Function<R, N> nextTransformation : nextTransformations) {
      cfq = cfq.thenCombineAsync(nextTransformation);
    }
    return cfq;
  }
1046299
@Override
   public Iterator<R> iterator() {
      log.tracef("Distributed iterator invoked with rehash: %s", rehashAware);
      if (!rehashAware) {
         // Non rehash doesn't care about lost segments or completed ones
         CloseableIterator<R> closeableIterator = nonRehashRemoteIterator(dm.getReadConsistentHash(), segmentsToFilter,
               null, IdentityPublisherDecorator.getInstance(), intermediateOperations);
         onClose(closeableIterator::close);
         return closeableIterator;
      } else {
         Iterable<IntermediateOperation> ops = iteratorOperation.prepareForIteration(intermediateOperations,
               (Function) nonNullKeyFunction());
         CloseableIterator<R> closeableIterator;
         if (segmentCompletionListener != null && iteratorOperation != IteratorOperation.FLAT_MAP) {
            closeableIterator = new CompletionListenerRehashIterator<>(ops, segmentCompletionListener);
         } else {
            closeableIterator = new RehashIterator<>(ops);
         }
         onClose(closeableIterator::close);
         // This cast messes up generic checking, but that is okay
         Function<R, R> function = iteratorOperation.getFunction();
         if (function != null) {
            return new IteratorMapper<>(closeableIterator, function);
         } else {
            return closeableIterator;
         }
      }
   }
576970
function (obj, iterator, context) {
    var results = [];
    if (!obj) return results;
    if (Array.prototype.map && obj.map === Array.prototype.map) {
      return obj.map(iterator, context);
    }
    each(obj, function (value, index, list) {
      results[results.length] = iterator.call(context, value, index, list);
    });
    if (obj.length === +obj.length) results.length = obj.length;
    return results;
  }
1330144
function iterateArray(array) {
  return ArrayCompiler.compileArray(array.map(function(obj) {
    return iterate(obj);
  }), data);
}
982992
public static <T> Iterator<Pair<Integer, T>> counted(T... array) {
        dbc.precondition(array != null, "cannot call counted with a null array");
        final SequencingPolicy<Integer> sequencer = new NextIntegerSequencingPolicy();
        final Comparator<Optional<Integer>> comparator = new JustBeforeNothingComparator<Integer>(new ComparableComparator<Integer>());
        final Range<Integer> range = new DenseRange<Integer>(sequencer, comparator, Endpoint.Include, 0, Optional.of(Integer.MAX_VALUE), Endpoint.Include);
        return new ZipShortestIterator<Integer, T>(range.iterator(), new ArrayIterator<T>(array));
    }
918394
public function each(array $collection, Closure $iterator)
    {
        foreach ($collection as $key => $node)
        {
            $iterator($key, $node);
        }
    }
494720
function asyncer (tasks, cb) {

    cb = cb || noop6;

    if (typpy(tasks, Function)) {
        if (tasks.length >= 1) {
            return tasks(cb);
        }
        return fnResult(tasks, cb);
    }

    let normalize = tsks => tsks.map(c => {
        if (typpy(c, Function) && c.length >= 1) {
            return c;
        }

        return done => {
            asyncer(c, done)
        };
    });

    if (typpy(tasks, Object)) {
        tasks = normalize(tasks.parallel || tasks.p);
        sameTime(tasks, cb);
        return;
    }

    if (typpy(tasks, Array)) {
        tasks = normalize(tasks);
        oneByOne(tasks, cb);
        return;
    }

    throw new TypeError("The tasks should be an array or an object.");
}
841856
private Scriptable makeIteratorResult(Context cx, Scriptable scope, boolean done, Object value) {
        Scriptable iteratorResult = cx.newObject(scope);
        ScriptableObject.putProperty(iteratorResult, VALUE_PROPERTY, value);
        ScriptableObject.putProperty(iteratorResult, DONE_PROPERTY, done);
        return iteratorResult;
    }
902322
@Override
    public Iterator iterate()
    {
        if (kunderaQuery.isNative())
        {
            throw new UnsupportedOperationException("Iteration not supported over native queries");
        }
        EntityMetadata m = getEntityMetadata();
        Client client = persistenceDelegeator.getClient(m);
        externalProperties = ((CassandraClientBase) client).getExternalProperties();

        if (!MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata()))
        {
            throw new UnsupportedOperationException("Scrolling over cassandra is unsupported for lucene queries");
        }

        return new DSResultIterator(this, m, persistenceDelegeator.getClient(m), this.getReader(),
                getFetchSize() != null ? getFetchSize() : this.maxResult, kunderaMetadata);
    }