-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdread.js
More file actions
31 lines (25 loc) · 711 Bytes
/
Copy pathdread.js
File metadata and controls
31 lines (25 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const configure = require('./configure');
const execute = require('./execute');
const { exp, JitterType } = require('./backoff');
const { prop, is, code, always } = require('./condition');
const defaults = {
attempts: 10,
condition: prop('retryable'),
backoff: exp(),
timeout: undefined,
};
module.exports = function dread() {
let task, config = defaults;
for (const arg of arguments) {
if (typeof arg === 'function') {
task = arg;
} else {
config = configure(arg, config);
}
}
return typeof task === 'function'
? execute(task, config)
: dread.bind(null, config);
};
Object.assign(module.exports, { prop, is, code, exp, always, JitterType });