-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
same as ramda's pipe
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const test = require('./config') | ||
const { pipe } = require('..') | ||
|
||
test('pass single argument to single function', t => { | ||
t.is(pipe(x => x + 2)(1), 3) | ||
}) | ||
|
||
test('pass multiple arguments to single function', t => { | ||
t.is(pipe( | ||
(x, y) => x + y | ||
)(1, 5), 6) | ||
t.is(pipe( | ||
(x, y, z) => x + y - z | ||
)(1, 2, 5), -2) | ||
}) | ||
|
||
test('chain multiple functions with single argument', t => { | ||
t.is(pipe( | ||
x => x + 1, | ||
y => y - 2 | ||
)(2), 1) | ||
t.is(pipe( | ||
x => x + 1, | ||
y => y - 2, | ||
z => z * 2 | ||
)(2), 2) | ||
}) | ||
|
||
test('chain multiple functions with multiple args', t => { | ||
t.is(pipe( | ||
(x, y) => x + y, | ||
z => z * 2 | ||
)(1, 3), 8) | ||
}) |