# outwork

> Fault tolerance patterns for TypeScript

Latest version **0.1.6** (published 2021-08-09) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2021-08-09 |
| First published | 2020-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 12.13 |
| Dependencies | 2 |
| Unpacked size | 35.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Dunnam |
| Maintainers | jimador |

## Links

- npm: https://www.npmjs.com/package/outwork
- npm.io page: https://npm.io/package/outwork

## Dependencies (2)

- [verror](https://npm.io/package/verror.md) ^1.10.0
- [winston](https://npm.io/package/winston.md) ^3.3.3

## Recent versions

- 0.1.6 (latest) — 2021-08-09
- 0.1.5 — 2021-08-09
- 0.1.3 — 2020-10-08
- 0.1.1 — 2020-10-07
- 0.1.0 — 2020-10-07

## README

![](https://github.com/jimador/outwork/workflows/build/badge.svg)

# Outwork

Fault tolerance tools for TypeScript

> out·work
>
> /ˈoutˌwərk/
>
> a section of a fortification or system of defense which is in front of the main part.

## Example Usage

As a Decorator

```ts
class SomeClass {
  @retry({
    maxAttempts: 3,
    backOff: 100,
    backOffPolicy: BackOffPolicy.CONSTANT,
    shouldRetry: (e: Error) => {
      return e.message === 'Error: 429'
    },
  })
  async someFnWithConstantRateRetries(): Promise<any> {
    throw new Error('Error: 404')
  }

  @retry({
    maxAttempts: 3,
    backOffPolicy: BackOffPolicy.EXPONENTIAL,
    maxDelay: 1000,
    minDelay: 100,
    jitter: true,
  })
  async someFnWithExponentialBackOffRetries(): Promise<any> {
    return new Promise((_, reject) => {
      reject(new Error('Broke'))
    })
  }
}
```

As a HoF:

```ts
const myAsyncFunc = async (num: number, str: string): Promise<void> => {...}

const myAsyncFuncWithRetries =
  withRetry(myAsyncFunc, {
    maxAttempts: 3,
    backOffPolicy: BackOffPolicy.EXPONENTIAL,
    maxDelay: 1000,
    minDelay: 100,
    jitter: true
  })
```

Tools:

- [TypeScript][typescript] [4.0][typescript-4-0]
- [ESLint][eslint]
- [Jest][jest]
- [Prettier][prettier]
- Reproducible environments with [Volta][volta]
  - [install][volta-getting-started] Volta
- .editorconfig for consistent file format
- [Dependabot] updates
- [KodiakHQ] automerges

## Available Scripts

- `build` - compile TS
- `build:watch` - interactive watch mode to automatically transpile source files
- `checkcommit` - validate commit message
- `clean` - remove coverage data, Jest cache and transpiled files,
- `clean-deps` - remove `node_modules`
- `clean-generated` - remove coverage and build directories and files
- `clean-logs` - remove log files
- `commit` - start commit
- `format` - format files
- `lint` - lint source files and tests,
- `nuke` - clean everything
- `sort-pj` - sort `package.json`
- `test` - run tests,
- `test:watch` - interactive watch mode to automatically re-run tests

[typescript]: https://www.typescriptlang.org/
[typescript-4-0]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html
[jest]: https://facebook.github.io/jest/
[eslint]: https://github.com/eslint/eslint
[prettier]: https://prettier.io
[volta]: https://volta.sh
[volta-getting-started]: https://docs.volta.sh/guide/getting-started
[dependabot]: https://dependabot.com/
[kodiakhq]: https://kodiakhq.com/

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