remeda
Version:
A utility library for JavaScript and Typescript.
47 lines (45 loc) • 1.89 kB
text/typescript
import { IterableContainer } from "./IterableContainer-JENOIFLG.cjs";
import { Mapped } from "./Mapped-DXkswSXD.cjs";
//#region src/map.d.ts
/**
* Creates a new array populated with the results of calling a provided function
* on every element in the calling array. Equivalent to `Array.prototype.map`.
*
* @param data - The array to map.
* @param callbackfn - A function to execute for each element in the array. Its
* return value is added as a single element in the new array.
* @returns A new array with each element being the result of the callback
* function.
* @signature
* R.map(data, callbackfn)
* @example
* R.map([1, 2, 3], R.multiply(2)); // => [2, 4, 6]
* R.map([0, 0], R.add(1)); // => [1, 1]
* R.map([0, 0], (value, index) => value + index); // => [0, 1]
* @dataFirst
* @lazy
* @category Array
*/
declare function map<T extends IterableContainer, U>(data: T, callbackfn: (value: T[number], index: number, data: T) => U): Mapped<T, U>;
/**
* Creates a new array populated with the results of calling a provided function
* on every element in the calling array. Equivalent to `Array.prototype.map`.
*
* @param callbackfn - A function to execute for each element in the array. Its
* return value is added as a single element in the new array.
* @returns A new array with each element being the result of the callback
* function.
* @signature
* R.map(callbackfn)(data)
* @example
* R.pipe([1, 2, 3], R.map(R.multiply(2))); // => [2, 4, 6]
* R.pipe([0, 0], R.map(R.add(1))); // => [1, 1]
* R.pipe([0, 0], R.map((value, index) => value + index)); // => [0, 1]
* @dataLast
* @lazy
* @category Array
*/
declare function map<T extends IterableContainer, U>(callbackfn: (value: T[number], index: number, data: T) => U): (data: T) => Mapped<T, U>;
//#endregion
export { map };
//# sourceMappingURL=map-ZMLoe5iZ.d.cts.map