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
- Host: GitHub
- URL: https://github.com/streetstrider/alt
- Owner: StreetStrider
- License: other
- Created: 2022-10-31T22:42:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-12T22:45:23.000Z (about 2 years ago)
- Last Synced: 2024-12-30T23:46:43.616Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
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.