import { map } from "https://deno.land/x/iter@v3.2.3/mod.ts";
Lazily calls a defined callback function for each element of an iterable, and returns a new iterable of the results.
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter/mod.ts";
const naturals = iter.create.increments(1);
const reciprocals = iter.map(naturals, n => n**-1);
const iterator = reciprocals[Symbol.iterator]();
console.log(iterator.next().value); // -> 1
console.log(iterator.next().value); // -> 0.5
console.log(iterator.next().value); // -> 0.3333333333333333
console.log(iterator.next().value); // -> 0.25
console.log(iterator.next().value); // -> 0.2
Type Parameters
optional
U = TParameters
it: Iterable<T>
- The iterable being mapped.
f: MapCallback<T, U>
- A function that accepts up to three arguments. The
map function calls
f
function one time for each item in the iterable.
Returns
An iterable of f
applied to items of it
.