# @synonymdev/result

> Result helper class

Latest version **0.0.2** (published 2022-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @synonymdev/result
pnpm add @synonymdev/result
yarn add @synonymdev/result
bun add @synonymdev/result
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2022-08-06 |
| First published | 2022-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason van den Berg |
| Maintainers | pwltr, miguelmedeirosweb, rbndg, chm-diederichs, bitcoinerrorlog, jayvdb, coreyphillips, gr0kchain, nzh |

## Links

- npm: https://www.npmjs.com/package/@synonymdev/result
- Repository: https://github.com/synonymdev/result
- Homepage: https://github.com/synonymdev/result#readme
- Issues: https://github.com/synonymdev/result/issues
- npm.io page: https://npm.io/package/@synonymdev/result

## Recent versions

- 0.0.2 (latest) — 2022-08-06

## README

# Result helper class

### Description
Result helper class

## Getting started

```bash
yarn add @synonymdev/result
#or
npm i -s @synonymdev/result
````

## Usage
```javascript
import { Result, err, ok } from '@synonymdev/result';
```

```typescript
const func = (): Result<number> => {
  return ok(42);
  // OR
  return err('error message');
  // OR
  return err(new Error('error message'));
}

const result = func();

if (result.isOk()) {
    console.log(result.value); //42
}

if (result.isErr()) {
    console.error(result.error.message); // "error message"
}
```


## Development

### `yarn build`

Builds library ready for production use.

### `yarn test`

Unit tests.

### `yarn format`

Code formatting.

### `yarn lint`

Code linting.

### `yarn prepublish`

Prepares code for publishing by building and bumping package version.

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