Sort out previous message logic
This commit is contained in:
parent
4bf9e3b678
commit
c1cf4c72df
10
index.js
10
index.js
|
@ -83,12 +83,12 @@ export default function pTimeout(promise, options) {
|
||||||
|
|
||||||
if (message === false) {
|
if (message === false) {
|
||||||
resolve();
|
resolve();
|
||||||
|
} else if (message instanceof Error) {
|
||||||
|
reject(message);
|
||||||
|
} else {
|
||||||
|
const errorMessage = message ?? `Promise timed out after ${milliseconds} milliseconds`;
|
||||||
|
reject(new TimeoutError(errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorMessage = typeof message === 'string' ? message : `Promise timed out after ${milliseconds} milliseconds`;
|
|
||||||
const timeoutError = message instanceof Error ? message : new TimeoutError(errorMessage);
|
|
||||||
|
|
||||||
reject(timeoutError);
|
|
||||||
}, milliseconds);
|
}, milliseconds);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
Loading…
Reference in New Issue