@zcong/aggregator
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @zcong/aggregator

Weekly Downloads

1

Version

0.3.1

License

MIT

Unpacked Size

7.2 kB

Total Files

9

Last publish

Collaborators

  • zcong