Creates a function that transforms each value in an iterable using a mapping function. Similar to Array.prototype.map, but for any iterable.
The type of elements in the input iterable
The type of elements in the output iterable
Function that transforms each value; receives value and index
A function that takes an iterable and yields mapped values
Values transformed by the mapping function
// Double each numberconst double = G.map(x => x * 2);const result = Array.from(double([1, 2, 3])); // [2, 4, 6]// Use with indexconst withIndex = G.map((x, i) => `${i}: ${x}`);const result2 = Array.from(withIndex(['a', 'b', 'c'])); // ['0: a', '1: b', '2: c'] Copy
// Double each numberconst double = G.map(x => x * 2);const result = Array.from(double([1, 2, 3])); // [2, 4, 6]// Use with indexconst withIndex = G.map((x, i) => `${i}: ${x}`);const result2 = Array.from(withIndex(['a', 'b', 'c'])); // ['0: a', '1: b', '2: c']
flatMap - For mapping one input to multiple outputs
Creates a function that transforms each value in an iterable using a mapping function. Similar to Array.prototype.map, but for any iterable.