@async-generator/map

like Array#map but for async generator

Usage no npm install needed!

<script type="module">
  import asyncGeneratorMap from 'https://cdn.skypack.dev/@async-generator/map';
</script>

README

take outputs from one generator and transform them

It's like Array#map but for AsyncGenerator

installation

> npm i @async-generator/map

usage

const map = require("@async-generator/map");
const interval = require("@async-generator/interval");

const input = interval(100);
const output = map(input, x => x * x);

const actual = [];

for await (const item of output) {
  console.log(item); // will log 0, 1, 4, 9, 16, 25, ...
}