Nighttime Possum Meandering
Introducing npm Teams! Private packages + team management tools.Learn more »

async-iterable-map

2.0.3 • Public • Published

async-iterable-map

Transforms items of an async iterable concurrently

npm Gitlab pipeline status Dependency Status devDependency Status

Like p-map but for AsyncIterables.

If you like this package, be sure to star its repo, and please consider donating.

Usage

import { map } from "async-iterable-map"

map(source, transform, options = {})

Generic type parameters:

  • T = unknown - type of input elements
  • U = unknown - type of output elements

Parameters:

  • source: AsyncIterable<T> | Iterable<T> - the iterable to transform
  • transform: (element: T) => Promise<U> | U - the transform / mapping function from the input to the output
  • options.concurrency: number - how many elements to transform concurrently. Must be a positive integer or Infinity. Default: Infinity

Returns:

  • AsyncIterableIterator<U> & PromiseLike<U[]>
    • Use the AsyncIterableIterator<U> interface to iterate through the remaining output elements one by one.
    • Use the PromiseLike<U[]> interface to get all of the remaining output elements.

Both interfaces return the output elements in order.

Transforms items of an async iterable concurrently.

Install

npm i async-iterable-map

DownloadsWeekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

11.8 kB

Total Files

12

Last publish

Collaborators

  • avatar