eine
v0.0.7
Published
🤿 functional try ... catch implementation
Downloads
2
Readme
eine 🤿
Dead simple, functional, curriable try ... catch implementation.
Install
npm i eine
Usage
TC - Try catch
import { tc } from 'eine'
const [error, value] = tc(() => {
// errorable code
return value
})
TCF - Try catch fallback
import { tcf } from 'eine'
const safeParseNum = tcf(0, parseNum)
// partial application to reuse
const tcNumber = tcf(0)
// other helpers
import { tcNull, tcNullish, tcRetry } from 'eine'
tcNull(fn) // tcf(null, fn)
tcNullish(fn) // tcf(undefined, fn)
tcNumber(fn) // tcf(0, fn)
tcRetry(fn) // tcf(fn, fn)