eine
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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)

Readme

Keywords

none

Package Sidebar

Install

npm i eine

Homepage

101.lu

Weekly Downloads

1

Version

0.0.7

License

MIT

Unpacked Size

9.65 kB

Total Files

9

Last publish

Collaborators

  • weltmx