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 — stream: refactor to use `validateAbortSignal` · nodejs/node@17b4e9b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • abort_controller.js
    • webstreams
      • readablestream.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/abort_controller.js‎

Copy file name to clipboardExpand all lines: lib/internal/abort_controller.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ ObjectDefineProperty(AbortController.prototype, SymbolToStringTag, {
406406
});
407407

408408
module.exports = {
409-
kAborted,
410409
AbortController,
411410
AbortSignal,
412411
ClonedAbortSignal,
Collapse file

‎lib/internal/webstreams/readablestream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/readablestream.js
+13-14Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,11 @@ const {
5858
} = require('internal/util');
5959

6060
const {
61+
validateAbortSignal,
6162
validateBuffer,
6263
validateObject,
6364
} = require('internal/validators');
6465

65-
const {
66-
kAborted,
67-
} = require('internal/abort_controller');
68-
6966
const {
7067
MessageChannel,
7168
} = require('internal/worker/io');
@@ -381,8 +378,9 @@ class ReadableStream {
381378
const preventClose = options?.preventClose;
382379
const signal = options?.signal;
383380

384-
if (signal !== undefined && signal?.[kAborted] === undefined)
385-
throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal);
381+
if (signal !== undefined) {
382+
validateAbortSignal(signal, 'options.signal');
383+
}
386384

387385
if (isReadableStreamLocked(this))
388386
throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
@@ -422,8 +420,9 @@ class ReadableStream {
422420
const preventClose = options?.preventClose;
423421
const signal = options?.signal;
424422

425-
if (signal !== undefined && signal?.[kAborted] === undefined)
426-
throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal);
423+
if (signal !== undefined) {
424+
validateAbortSignal(signal, 'options.signal');
425+
}
427426

428427
if (isReadableStreamLocked(this))
429428
throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
@@ -1269,12 +1268,12 @@ function readableStreamPipeTo(
12691268

12701269
let shuttingDown = false;
12711270

1272-
if (signal !== undefined && signal?.[kAborted] === undefined) {
1273-
return PromiseReject(
1274-
new ERR_INVALID_ARG_TYPE(
1275-
'options.signal',
1276-
'AbortSignal',
1277-
signal));
1271+
if (signal !== undefined) {
1272+
try {
1273+
validateAbortSignal(signal, 'options.signal');
1274+
} catch (error) {
1275+
return PromiseReject(error);
1276+
}
12781277
}
12791278

12801279
const promise = createDeferredPromise();

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.