@monstermann/fn
Version:
A utility library for TypeScript.
31 lines • 1.05 kB
TypeScript
//#region src/set/mapEach.d.ts
/**
* `mapEach(target, fn)`
*
* Transforms each value in the `target` set using the `fn` function and returns a new set with the transformed values.
*
* ```ts
* mapEach(new Set([1, 2, 3]), (x) => x * 2); // Set([2, 4, 6])
* mapEach(new Set(["a", "b"]), (x) => x.toUpperCase()); // Set(['A', 'B'])
* ```
*
* ```ts
* pipe(
* new Set([1, 2, 3]),
* mapEach((x) => x * 2),
* ); // Set([2, 4, 6])
*
* pipe(
* new Set(["a", "b"]),
* mapEach((x) => x.toUpperCase()),
* ); // Set(['A', 'B'])
* ```
*/
declare const mapEach: {
<T, U>(fn: (value: NoInfer<T>, target: ReadonlySet<NoInfer<T>>) => U): (target: Set<T>) => Set<U>;
<T, U>(fn: (value: NoInfer<T>, target: ReadonlySet<NoInfer<T>>) => U): (target: ReadonlySet<T>) => ReadonlySet<U>;
<T, U>(target: Set<T>, fn: (value: NoInfer<T>, target: ReadonlySet<NoInfer<T>>) => U): Set<U>;
<T, U>(target: ReadonlySet<T>, fn: (value: NoInfer<T>, target: ReadonlySet<NoInfer<T>>) => U): ReadonlySet<U>;
};
//#endregion
export { mapEach };