UNPKG

axax

Version:

A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).

18 lines (17 loc) 418 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Take the first x values from an async iterable */ function take(numberToTake) { return async function* inner(source) { let index = 0; for await (const item of source) { if (index++ >= numberToTake) { break; } yield item; } }; } exports.take = take;