0.0.7 • Published 11 months ago

eine v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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)