* Returns a Promise that resolves or rejects in approximately the specified amount of time with * the specified value or error reason. * @param {number} ms time in milliseconds in which to resolve or reject * @param {*} value value used for resolve * @param {string} [rejectionReason] reason used
(ms, value, rejectionReason)
| 72 | * @returns {Promise<*>} a promise of the value type |
| 73 | */ |
| 74 | function delayed(ms, value, rejectionReason) { |
| 75 | var error; |
| 76 | if (rejectionReason) { |
| 77 | error = new Error(rejectionReason); |
| 78 | } |
| 79 | return new Promise(function (resolve, reject) { |
| 80 | var id = setTimeout(function () { |
| 81 | clearTimeout(id); |
| 82 | if (error) { |
| 83 | reject(error); |
| 84 | } else { |
| 85 | resolve(value); |
| 86 | } |
| 87 | }, ms); |
| 88 | }); |
| 89 | } |
| 90 | |
| 91 | module.exports.createRequest = createRequest; |
| 92 | module.exports.createRequestSignature = createRequestSignature; |
no outgoing calls
no test coverage detected