1.0.0 • Published 6 months ago
ts-space-wrap v1.0.0
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
})
1.0.0
6 months ago