+5
-0
@@ -88,2 +88,7 @@ // Utils | ||
| export const mapChain = | ||
| (...fns) => | ||
| xs => | ||
| fns.reduce((acc, fn) => acc.map(fn), xs) | ||
| export const forEach = fn => xs => xs.forEach(fn ?? identity) | ||
@@ -90,0 +95,0 @@ |
+27
-0
@@ -527,2 +527,29 @@ ## Table of Contents | ||
| ### `mapChain` | ||
| **Description:** | ||
| Applies multiple transformation functions in sequence using `.map()` for each. | ||
| Equivalent to chaining multiple `.map(...)` calls, but written in a compact, composable form. | ||
| ```js | ||
| const mapChain = (...fns) => xs => | ||
| fns.reduce((acc, fn) => acc.map(fn), xs) | ||
| ``` | ||
| ```js | ||
| const double = x => x * 2 | ||
| const square = x => x * x | ||
| const negate = x => -x | ||
| const transform = mapChain(double, square, negate) | ||
| transform([1, 2, 3]) // → [-4, -16, -36] | ||
| // Explanation: | ||
| // [1, 2, 3] | ||
| // → [2, 4, 6] // after double | ||
| // → [4, 16, 36] // after square | ||
| // → [-4, -16, -36] // after negate | ||
| ``` | ||
| ### `partition` | ||
@@ -529,0 +556,0 @@ |
+1
-1
| { | ||
| "name": "nejquery", | ||
| "version": "5.5.7", | ||
| "version": "5.5.8", | ||
| "author": "bmehder", | ||
@@ -5,0 +5,0 @@ "private": false, |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
67588
1.08%399
1.01%