ts-space-wrap

1.0.0 • Public • Published

TS-Wrap

  • Wrap your of results (or promises of results) to create elegant type safe code

Examples

Archaic error handling

const result1 = someOperation()

if (!result.ok) {
  const result2 = someOperation2(result.error)

  if (!result2.ok) {
    // Do more things
  }
} else {
   const result3 = someOperation3(result.value)

   if (!result.ok) {
      // Some stuff
   }
   // More of that stuff
}

TS-Wrap error handling

const result =
  wrap(someOperation())
  .ifOkthen(async okValue => {
   // Some stuff here
  })
  .ifErrThen(async errValue => {
   // ErrorHandling stuff
  })
  .ifOkthen(async okValue => {
    // More stuff here
  })

/ts-space-wrap/

    Package Sidebar

    Install

    npm i ts-space-wrap

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    15.1 kB

    Total Files

    4

    Last publish

    Collaborators

    • vduong