# @fernando.vasquez/either-factory

> Either abstraction implementation.

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

## Install

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

## 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.1 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-factory
- npm.io page: https://npm.io/package/@fernando.vasquez/either-factory

## 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 { createLeft, createRight } = require("@fernando.vasquez/either-class");
```

### Instances on Right and Left
```javascript
// Right object
const right = createRight("foo", { foo: "bar" }]);

// Left object
const left = createLeft("foo", { foo: "bar" }]);
```

### Exmaple
```javascript
const { createLeft, createRight } = require("@fernando.vasquez/either-class");

const prop = (key, object) =>
  key in object
    ? createRight(object[key])
    : 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-factory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
