Created
April 3, 2018 12:38
-
-
Save indongyoo/7c83cb25ada44d9865c7fb9aaa68e886 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const isNagativeNumber = a => a < 0; | |
const f7 = pipe( | |
a => a - 10, | |
a => a + 100 | |
).exception(isNagativeNumber) ( | |
_ => console.log('중간에 빠져나옴') | |
); | |
console.log( f7(10) ); // 100 | |
console.log( f7(5) ); // // undefined 리턴되고, exception으로 가서 중간에 빠져나옴 출력 | |
const f8 = pipe( | |
a => ({ status: a }), | |
a => a + 100 | |
).exception(e => e && e.status == 1) ( | |
e => console.log('e 1') | |
).exception(e => e && e.status == 2) ( | |
e => console.log('e 2') | |
); | |
f8(1); // e 1 | |
f8(2); // e 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment