# @fernando.vasquez/either-prototype

> Either abstraction implementation.

Latest version **1.0.1** (published 2019-11-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @fernando.vasquez/either-prototype
pnpm add @fernando.vasquez/either-prototype
yarn add @fernando.vasquez/either-prototype
bun add @fernando.vasquez/either-prototype
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-11-28 |
| First published | 2019-11-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fernando Vásquez |
| Maintainers | fernando.vasquez |
| Keywords | either |

## Links

- npm: https://www.npmjs.com/package/@fernando.vasquez/either-prototype
- npm.io page: https://npm.io/package/@fernando.vasquez/either-prototype

## Recent versions

- 1.0.1 (latest) — 2019-11-28
- 1.0.0 — 2019-11-28

## README

# Either abstraction module
## Get Started

### Load the module
```javascript
// Loding the module
const Either = require("@fernando.vasquez/either-class");
```

### Instances on Either, Right and Left
```javascript
// Intance of Either
const either = new Either();

// Right object
const right = either.createRight("foo", { foo: "bar" }]);

// Left object
const left = either.createLeft("foo", { foo: "bar" }]);
```

### Exmaple
```javascript
const Either = require("@fernando.vasquez/either-class");
const either = new Either();

const prop = (key, object) =>
  key in object
    ? either.createRight(object[key])
    : either.createLeft(`Cannot read property '${key}'`);

const foobar = prop("foo", { foo: "bar" });
const bazbar = prop("baz", { foo: "bar" });

console.log(foobar.map(word => `${word}!`));                             // -> Right("bar!")
console.log(bazbar.map(word => `${word}!`));                             // -> Left("Cannot read property 'baz'")
foobar.runEither(error => console.error(new Error(error)), console.log); // -> foo
bazbar.runEither(error => console.error(new Error(error)), console.log); // -> Error: "Cannot read property 'baz'" at ...
console.log(prop("foo", { foo: "bar" }).getType());                      // -> 'Either'
console.log(prop("baz", { foo: "bar" }).getType());                      // -> 'Either'

```

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