fast-fallback
Fast fallback Lib that supports P-cancelable.
Install
yarn add fast-fallback
//es6; //commonjsconst fallback = ;
browser
Usage
Basic
const fallback = ;const PCancelable = ; const servers = '121.25.1.100' '121.25.1.101' '121.2.15.102' const asyncTransformer = { const ws = 'ws://' + server // Cancel late-successful connections. ws ws }; { const ws = await ws}
Currying
const curried = const results1 = await const results2 = await
API
fallback(values, asyncTransformer [, options])
values: array
Candidate values.
asyncTransformer: (val, idx) => PCancelable<Any>|Promise<Any>
Transform functions that generate promise using candidate value.
options: object
count
Number of fallback results. defaults 1
.
concurrency
Number of concurrently processing promises. defaults Infinity
.
silent
When all promises fail, return an empty array if true, or throw an exception if false.
defaults false
.
Related
- promise-cancelable - for browser
- p-cancelable - for node
License
MIT