Node Permanently Moved

    promise.map
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.1 • Public • Published

    promise.map

    Promise.map

    Build Status Coverage Status npm version npm downloads npm license

    Install

    $ npm i -S promise.map

    API

    pmap

    export default function pmap<IN, OUT>(
      arr: IN[],
      fn: (item: IN, index: number, arr: IN[]) => Promise<OUT> | OUT,
      concurrency: number
    ): Promise<OUT[]>
    var p = pmap(
      arr,
      function (item, index, arr) {
        return getOtherPromise(item)
      },
      concurrency
    )

    map on Workers: pmapWorker

    for cpu heavy work, you can map on workers

    export function pmapWorker<IN, OUT, AnyWorker extends Object>(
      arr: IN[],
      fn: (item: IN, index: number, arr: IN[], worker: AnyWorker) => Promise<OUT>,
      workers: AnyWorker[]
    ): Promise<OUT[]>

    Why

    • bluebird is awesome, and provide tons of convience methods, such as Promise.map, it provides async.parallelLimit but, it got some opinioned ways, like this warn. So we'd better split things out.
    • package promise-map simply use Array.prototype.map, that lost a concurrency or parallelLimit control

    See Also

    Changelog

    CHANGELOG.md

    License

    the MIT License http://magicdawn.mit-license.org

    Install

    npm i promise.map

    DownloadsWeekly Downloads

    537

    Version

    0.3.1

    License

    MIT

    Unpacked Size

    8.04 kB

    Total Files

    8

    Last publish

    Collaborators

    • magicdawn