# result-handler

> Result Handler

Latest version **0.2.0-rc.2** (published 2020-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install result-handler
pnpm add result-handler
yarn add result-handler
bun add result-handler
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0-rc.2 |
| Published | 2020-04-10 |
| First published | 2018-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stephen-Murphy |
| Maintainers | stephenmurphy |

## Links

- npm: https://www.npmjs.com/package/result-handler
- Repository: https://github.com/Stephen-Murphy/ResultHandler
- Homepage: https://github.com/Stephen-Murphy/ResultHandler#readme
- Issues: https://github.com/Stephen-Murphy/ResultHandler/issues
- npm.io page: https://npm.io/package/result-handler

## Recent versions

- 0.2.0-rc.2 (latest) — 2020-04-10
- 0.2.0-rc.4 (next) — 2020-04-26
- 0.2.0-rc.3 — 2020-04-10
- 0.2.0-rc.1 — 2020-04-10
- 0.1.1-rc.1 — 2019-07-19
- 0.1.0 — 2019-07-18
- 0.1.0-rc1 — 2018-11-23
- 0.0.7 — 2018-11-22
- 0.0.6 — 2018-11-22
- 0.0.5 — 2018-11-20
- 0.0.4 — 2018-11-20
- 0.0.3 — 2018-11-20
- 0.0.2 — 2018-11-20
- 0.0.1 — 2018-11-20

## README

# Result Handler


````sh
npm i result-handler
````

Usage with classes

````typescript
import { Result } from 'result-handler';

class MyTestClass {

    createResult: ResultHandler;

    constructor() {
        this.createResult = Result.Handler(MyTestClass);
    }

    someMethod(): Result<number> {
        const result = this.createResult<number>(this.someMethod);
        if (Math.random() > 0.1) {
            return result.success(5);
        } else {
            return result.failure('');
        }
    }

    alwaysFails() {
        return Result.Failure('message');
    }

    alwaysSucceeds() {
        return Result.Success(123);
    }

    mayFail() {
        if (shouldFail) {
            return Result.Failure('message');
        } else {
            return result.Success(123);
        }
    }

    throws() {
        const r = new Result();
        r.throw('some message');
    }

}

````

### TODO's
- full tests/coverage
- badges

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