ts-space-wrap
v1.0.0
Published
- Wrap your of results (or promises of results) to create elegant type safe code
Downloads
1
Readme
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
})