0.3.1 • Published 3 years ago

@zcong/aggregator v0.3.1

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

aggregator

NPM version NPM downloads JS Test codecov

promise aggregator

Install

$ yarn add @zcong/aggregator
# or npm
$ npm i @zcong/aggregator --save

Usage

import { aggregator, withDefaultValue } from '@zcong/aggregator'

// call multi API concurrency
aggregator([
  {
    fn: () => callImportantAPI(), // will throw when callImportantAPI fail
  },
  {
    fn: () => callOptionalAPI(), // will return fallbackFn when callOptionalAPI fail
    fallbackFn: withDefaultValue({ defaultData: 'defaultData' }),
  },
  {
    fn: () => callOptionalAPI2(),
    fallbackFn: () => callFallbackAPI(), // not use static value
  },
]).then(([importantResp, optionalResp]) => {})

License

MIT © zcong1993

0.3.1

3 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago