X Tutup
The Wayback Machine - https://web.archive.org/web/20230220192802/https://github.com/nodejs/node/commit/1b74a08eba
Skip to content
Permalink
Browse files
timers: refactor to use validateAbortSignal
PR-URL: #36604
Backport-PR-URL: #38386
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
  • Loading branch information
Lxxyx authored and targos committed Apr 30, 2021
1 parent 385e8e8 commit 1b74a08
Showing 1 changed file with 10 additions and 18 deletions.
@@ -16,6 +16,8 @@ const {
codes: { ERR_INVALID_ARG_TYPE }
} = require('internal/errors');

const { validateAbortSignal } = require('internal/validators');

let DOMException;

const lazyDOMException = hideStackFrames((message, name) => {
@@ -34,15 +36,10 @@ function setTimeout(after, value, options = {}) {
options));
}
const { signal, ref = true } = options;
if (signal !== undefined &&
(signal === null ||
typeof signal !== 'object' ||
!('aborted' in signal))) {
return PromiseReject(
new ERR_INVALID_ARG_TYPE(
'options.signal',
'AbortSignal',
signal));
try {
validateAbortSignal(signal, 'options.signal');
} catch (err) {
return PromiseReject(err);
}
if (typeof ref !== 'boolean') {
return PromiseReject(
@@ -83,15 +80,10 @@ function setImmediate(value, options = {}) {
options));
}
const { signal, ref = true } = options;
if (signal !== undefined &&
(signal === null ||
typeof signal !== 'object' ||
!('aborted' in signal))) {
return PromiseReject(
new ERR_INVALID_ARG_TYPE(
'options.signal',
'AbortSignal',
signal));
try {
validateAbortSignal(signal, 'options.signal');
} catch (err) {
return PromiseReject(err);
}
if (typeof ref !== 'boolean') {
return PromiseReject(

0 comments on commit 1b74a08

Please sign in to comment.
X Tutup