项目作者: alexandrosntak

项目描述 :
A forEach loop for applying asynchronous functions to items in iterable objects
高级语言: TypeScript
项目地址: git://github.com/alexandrosntak/forEachAsync.git
创建时间: 2017-02-11T10:00:33Z
项目社区:https://github.com/alexandrosntak/forEachAsync

开源协议:The Unlicense

下载


forEachAsync

A forEach loop for applying asynchronous functions to items in iterable objects

How to use:

forEachAsync ( objectLiteralOrArray, doOnIteration, doAfterLastIteration )

  • objectLiteralOrArray: The object or array you are iterating over
  • doOnIteration ( item, indexOrKey, next )
    • item: the item you want to apply your asynchronous function
    • indexOrKey: the current iteration index or key
    • next (): return this function to move to the next item [1]
  • doAfterLastIteration ()

Notes:

  1. Tail Calls: Returning the next() function is important with ES6. In case you accidentally
    iterate with a synchronous function over a big iterable, there is a chance
    that your stack will overflow. That’s why tail-calling next() could be important.
    Read more here:

    http://stackoverflow.com/questions/23260390/node-js-tail-call-optimization-possible-or-not
    http://2ality.com/2014/04/call-stack-size.html