Comparing version 0.0.6 to 0.0.7
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"scripts": { | ||
@@ -19,0 +19,0 @@ "lint": "tslint --project ./tsconfig.json", |
@@ -30,5 +30,7 @@ # pipe-ts | ||
Allows first function to have multiple parameters, [using generic rest parameters](https://github.com/Microsoft/TypeScript/issues/29904#issuecomment-471334674) | ||
Allows first function to have any number of parameters (0+), [thanks to TypeScript's generic rest parameters](https://github.com/Microsoft/TypeScript/issues/29904#issuecomment-471334674) | ||
```ts | ||
// First function has multiple parameters | ||
const difference = (a: number, b: number) => a - b; | ||
@@ -46,2 +48,17 @@ const add1 = (n: number) => n + 1; | ||
```ts | ||
// First function has 0 parameters | ||
const getNumber = () => 1; | ||
const add1 = (n: number) => n + 1; | ||
const getNumberThenAdd1 = pipe( | ||
getNumber, | ||
add1, | ||
); | ||
const result: number = getNumberThenAdd1(); | ||
assert.strictEqual(result, 2); | ||
``` | ||
## `pipeWith` | ||
@@ -62,4 +79,6 @@ | ||
`pipe` and `pipeWith` currently support up to 9 functions. If need be, we are open to adding more overloads to avoid this. | ||
`pipe` and `pipeWith` currently support up to 9 functions. If need be, we are open to adding more overloads to increase this limit. | ||
We are [also open to adding an array overload](https://github.com/unsplash/pipe-ts/issues/5), so any number of funtions can be passed. | ||
## Development | ||
@@ -66,0 +85,0 @@ |
@@ -5,2 +5,3 @@ "use strict"; | ||
var index_1 = require("./index"); | ||
var zeroParamGetNumber = function () { return 1; }; | ||
var singleParamFnAdd1 = function (n) { return n + 1; }; | ||
@@ -20,3 +21,3 @@ var singleParamFnTimes2 = function (n) { return n * 2; }; | ||
it('works when first function has 0 params', function () { | ||
assert.strictEqual(index_1.pipe(function () { return 1; }, singleParamFnAdd1)(), 2); | ||
assert.strictEqual(index_1.pipe(zeroParamGetNumber, singleParamFnAdd1)(), 2); | ||
}); | ||
@@ -23,0 +24,0 @@ it('works when first function has single param', function () { |
Sorry, the diff of this file is not supported yet
14615
97
87