Transforms items to new ones

Usage no npm install needed!

<script type="module">
  import agenMap from 'https://cdn.skypack.dev/@agen/map';



Transform items from the parent async generator to new values.

This method accepts the following parameters:

  • generator - asynchronous generator providing inidvidual items
  • map - method transforming the initial item

It returns an asynchronous generator providing transformed items.


const batch = require('@agen/map');

const list = [ 'a', 'b', 'c' ]
for await (let item of map(list, (v, i) => v.toUpperCase()) {
  console.log('-', item);
// Will print
// - A
// - B
// - C