An open API service indexing awesome lists of open source software.

https://github.com/streetstrider/alt

generalization over Option, Either, Result and others for the practical use in JavaScript apps
https://github.com/streetstrider/alt

Last synced: 4 months ago
JSON representation

generalization over Option, Either, Result and others for the practical use in JavaScript apps

Awesome Lists containing this project

README

          

# Alt

Generalization over Option, Either, Result and others for the practical use in JavaScript apps.

```jsx
function View () {
const [ state, _ ] = useSomeState()

useEffect(() => {
state.tap_of('ERROR', error => console.error(error))
}, [ state ])

return


{
state
.map(data => )
.settle_of('PROGRESS', () => )
.settle_of('ERROR', error =>
Error: { error.message }
)
.extract()
}

}
```

`extract` takes OK value out of the Alt. It is exhaustive. If Alt is not settled to OK only it will return `unknown` type in static time and throw in run time.

## license

ISC, © Strider, 2024.