Sort out previous message logic

This commit is contained in:
Federico Brigante 2022-11-25 17:01:57 +08:00
parent 4bf9e3b678
commit c1cf4c72df
1 changed files with 5 additions and 5 deletions

View File

@ -83,12 +83,12 @@ export default function pTimeout(promise, options) {
if (message === false) {
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);
(async () => {