0.1.6 • Published 3 years ago

outwork v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

npm.io

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

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:

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:

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
0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago