# eithery

> ## Install

Latest version **0.3.0** (published 2019-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install eithery
pnpm add eithery
yarn add eithery
bun add eithery
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2019-12-01 |
| First published | 2019-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 46.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sascha245 |
| Keywords | eithery, either, async |

## Links

- npm: https://www.npmjs.com/package/eithery
- Repository: https://github.com/sascha245/eithery
- Homepage: https://github.com/sascha245/eithery#readme
- Issues: https://github.com/sascha245/eithery/issues
- npm.io page: https://npm.io/package/eithery

## Recent versions

- 0.3.0 (latest) — 2019-12-01
- 0.2.0 — 2019-12-01
- 0.1.0 — 2019-11-18
- 0.0.1 — 2019-11-17

## README

# eithery

## Install

`npm install eithery --save`

## Usage

Fully typed Either type with fluent syntax and async support.

No usage available yet, but here a small example of what this library looks like:

```ts

const isForbidden = async (x: number) => {
  const isForbidden = await isForbiddenNumber(x);
  return isForbidden ? left('ForbiddenNumber' as const) : right(x);
};

const divideByN = (x: number) => (x === 0 ? left('DivideByZero' as const) : right(1 / x));

// Autocompletes as {Either<"DivideByZero", number>}
const result = right(42)
  .chain(divideByN)
  .map(x => x * 2)
  .tap(x => console.log('Current value: ', x));

// Autocompletes as {EitherAsync<"ForbiddenNumber" | "DivideByZero", number>}
const resultAsync = right(42)
  .chainAsync(isForbidden)
  .chain(divideByN)
  .map(x => x * 2)
  .mapAsync(async x => x * 2)
  .tap(x => console.log('Current value: ', x));

// You can await EitherAsync to get a simple Either
const awaitedResult = await resultAsync;

```

## Contributors

If you are interested and want to help out, don't hesitate to contact me or to create a pull request with your fixes / features.

1. Clone the repository

2. Install dependencies
`npm install`

4. Launch unit tests situated in *./tests*. The unit tests are written in Jest.
`npm run test:unit`

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

---
_Source: https://npm.io/package/eithery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
