1 | import wait from './wait.js';
|
2 |
|
3 | /**
|
4 | * Returns a function that returns a Promise that rejects with provided args after a delay.
|
5 | *
|
6 | * @function rejectAfterWith
|
7 | * @category Higher-order
|
8 | *
|
9 | * @arg {Number} [duration=0] - Milliseconds
|
10 | * @arg {*} [args] - Passed in to the reject function.
|
11 | *
|
12 | * @returns {function(): Promise}
|
13 | */
|
14 | export default (duration, ...args) => () => wait((resolve, reject) => {
|
15 | wait(duration).then(() => reject(...args));
|
16 | });
|