$ cnpm install @iocmd/hold-up
hold up is setInterval with promises, counter and error handling.
It runs a function and if it throws run it again with interval (defaults to 1 second) counter times (defaults to 5). If it fails, promise throws, if successed resolves.
npm i @iocmd/hold-up --save
fn - functionargs - array of argumentsoptions - options may contain:
logcounttimeconst holdUp = require('hold-up');
const fn = async (a = 'hello') => {
throw Error(a);
};
await holdUp(fn);
// reject in a 5 seconds
// [Error: hello]
// with arguments
await holdUp([fn, 'world']);
// reject in a 5 seconds
//[Error: hello]
// when you need to override options,
await holdUp([fn, 'hello'], {
count: 5, // default
time: 1000, // default
log: () => {}, // default
});
currify - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments.
fullstore - functional variables.
wraptile - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of 2 functions, each with a any count of arguments.
MIT
Copyright 2013 - present © cnpmjs.org | Home |