Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Created April 3, 2018 12:38
Show Gist options
  • Save indongyoo/7c83cb25ada44d9865c7fb9aaa68e886 to your computer and use it in GitHub Desktop.
Save indongyoo/7c83cb25ada44d9865c7fb9aaa68e886 to your computer and use it in GitHub Desktop.
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