GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — timers: refactor to use validateAbortSignal · nodejs/node@1b74a08

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/timers
    • promises.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/timers/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/timers/promises.js
+10-18Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const {
1616
codes: { ERR_INVALID_ARG_TYPE }
1717
} = require('internal/errors');
1818

19+
const { validateAbortSignal } = require('internal/validators');
20+
1921
let DOMException;
2022

2123
const lazyDOMException = hideStackFrames((message, name) => {
@@ -34,15 +36,10 @@ function setTimeout(after, value, options = {}) {
3436
options));
3537
}
3638
const { signal, ref = true } = options;
37-
if (signal !== undefined &&
38-
(signal === null ||
39-
typeof signal !== 'object' ||
40-
!('aborted' in signal))) {
41-
return PromiseReject(
42-
new ERR_INVALID_ARG_TYPE(
43-
'options.signal',
44-
'AbortSignal',
45-
signal));
39+
try {
40+
validateAbortSignal(signal, 'options.signal');
41+
} catch (err) {
42+
return PromiseReject(err);
4643
}
4744
if (typeof ref !== 'boolean') {
4845
return PromiseReject(
@@ -83,15 +80,10 @@ function setImmediate(value, options = {}) {
8380
options));
8481
}
8582
const { signal, ref = true } = options;
86-
if (signal !== undefined &&
87-
(signal === null ||
88-
typeof signal !== 'object' ||
89-
!('aborted' in signal))) {
90-
return PromiseReject(
91-
new ERR_INVALID_ARG_TYPE(
92-
'options.signal',
93-
'AbortSignal',
94-
signal));
83+
try {
84+
validateAbortSignal(signal, 'options.signal');
85+
} catch (err) {
86+
return PromiseReject(err);
9587
}
9688
if (typeof ref !== 'boolean') {
9789
return PromiseReject(

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.