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).
15 lines (14 loc) • 359 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Runs a mapping function over an asynchronous iterable
*/
function map(mapper) {
return async function* inner(source) {
let index = 0;
for await (const item of source) {
yield await mapper(item, index++);
}
};
}
exports.map = map;