@common-utilities/compose
Advanced tools
Comparing version 0.0.8 to 0.0.10
/** | ||
* compose 🚂 | ||
* ---- | ||
* a common function that take the output from one function | ||
* a common function that takes the output from one function | ||
* and automatically patches it to the input of the next function | ||
@@ -6,0 +6,0 @@ * until it spits out the final value |
@@ -7,3 +7,3 @@ "use strict"; | ||
* ---- | ||
* a common function that take the output from one function | ||
* a common function that takes the output from one function | ||
* and automatically patches it to the input of the next function | ||
@@ -15,4 +15,5 @@ * until it spits out the final value | ||
*/ | ||
exports.compose = (...fns) => (patchedValue) => fns.reduceRight((fnVal, fn) => fn(fnVal), patchedValue); | ||
const compose = (...fns) => (patchedValue) => fns.reduceRight((fnVal, fn) => fn(fnVal), patchedValue); | ||
exports.compose = compose; | ||
exports.default = exports.compose; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@common-utilities/compose", | ||
"version": "0.0.8", | ||
"version": "0.0.10", | ||
"description": "A basic implementation of the common utility function, Compose 🚂", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "3de4a71ca5c0192f988bfdede188fc72f941f9a4" | ||
"gitHead": "896fa6971331656a6762f2215104bf5d01fbe21c" | ||
} |
@@ -18,13 +18,9 @@ # @common-utilities/compose 🧰 🚂 | ||
```typescript | ||
```javascript | ||
const compose = (...fns) => (val) => fns.reduceRight((fnVal, fn) => fn(fnVal), val) | ||
``` | ||
```typescript | ||
const compose = (...fns: Function[]) => (val: any) => fns.reduceRight((fnVal: any, fn: Function) => fn(fnVal), val) | ||
``` | ||
## Usage | ||
```typescript | ||
```javascript | ||
const add1 = (val) => val + 1 | ||
@@ -31,0 +27,0 @@ const subtract2 = (val) => val - 2 |
/** | ||
* compose 🚂 | ||
* ---- | ||
* a common function that take the output from one function | ||
* a common function that takes the output from one function | ||
* and automatically patches it to the input of the next function | ||
@@ -12,4 +12,4 @@ * until it spits out the final value | ||
export const compose = (...fns: unknown[]) => (patchedValue: unknown): unknown => | ||
fns.reduceRight((fnVal: unknown, fn: Function) => fn(fnVal), patchedValue) | ||
fns.reduceRight((fnVal: unknown, fn: (fnVal: unknown) => unknown) => fn(fnVal), patchedValue) | ||
export default compose |
Sorry, the diff of this file is not supported yet
60
5250
43