Skip to content

Commit d10d851

Browse files
mcollinaclaude
andcommitted
src,lib: format and lint the webstreams engine
clang-format over src/streams (clearing 42 of the 45 cpplint findings; the remaining three were util.h/util-inl.h double includes) and a full eslint pass over lib/internal/webstreams: ReflectApply with array-literal arguments becomes FunctionPrototypeCall, read-result literals go done-first, tee branches and from()'s stream become const, JSDoc @returns added to the public constructors, non-ASCII punctuation swept from comments, and unused/missing primordials imports fixed. Zero eslint and cpplint findings remain in the flipped files. No behavior change intended. WPT streams 1404 (plain and --stress-incremental-marking), compression plus x3 stress, encoding, and the parallel whatwg/webstream suites green; readable-read official rows and the byte/transform spot shapes re-measured unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 277268f commit d10d851

13 files changed

Lines changed: 867 additions & 590 deletions

lib/internal/webstreams/readablestream.js

Lines changed: 52 additions & 55 deletions
Large diffs are not rendered by default.

lib/internal/webstreams/transfer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
PromiseResolve,
66
PromiseWithResolvers,
77
ReflectConstruct,
8+
Symbol,
89
} = primordials;
910

1011
const {

lib/internal/webstreams/transformstream.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict';
22

33
const {
4+
FunctionPrototypeCall,
45
ObjectDefineProperties,
56
ObjectDefineProperty,
67
ObjectGetOwnPropertyDescriptor,
78
ObjectPrototypeIsPrototypeOf,
89
ObjectSetPrototypeOf,
9-
ReflectApply,
10-
Symbol,
1110
SymbolToStringTag,
1211
} = primordials;
1312

@@ -64,8 +63,8 @@ const {
6463

6564
// A TransformStream's readable/writable halves are created in C++ and share the
6665
// native ReadableStream/WritableStream prototypes. The public decorations
67-
// (getReader/getWriter/pipeTo/inspect/transfer/) are grafted onto those
68-
// prototypes when these modules load but a transform-only program may never
66+
// (getReader/getWriter/pipeTo/inspect/transfer/...) are grafted onto those
67+
// prototypes when these modules load - but a transform-only program may never
6968
// touch the ReadableStream/WritableStream globals, so require them eagerly to
7069
// guarantee the grafts are installed. (readablestream pulls in writablestream.)
7170
require('internal/webstreams/readablestream');
@@ -80,7 +79,7 @@ const isTransformStream = (value) =>
8079
const isTransformStreamDefaultController = (value) =>
8180
value != null &&
8281
ObjectPrototypeIsPrototypeOf(TransformStreamDefaultControllerNative.prototype,
83-
value);
82+
value);
8483

8584
const hiddenMethodProp = (value) => ({
8685
__proto__: null, configurable: true, enumerable: false, writable: true, value,
@@ -97,6 +96,7 @@ async function defaultTransformAlgorithm(chunk, controller) {
9796
/**
9897
* The public TransformStream interface; the returned object is the C++
9998
* TransformStream that orchestrates its readable + writable halves.
99+
* @returns {TransformStream}
100100
*/
101101
function TransformStream(
102102
transformer = kEmptyObject,
@@ -138,7 +138,7 @@ function TransformStream(
138138
// undefined: both halves then skip the start-promise plumbing entirely and
139139
// mark their controllers started via the shared per-realm reaction.
140140
const startAlgorithm = start !== undefined ?
141-
(controller) => ReflectApply(start, transformer, [controller]) :
141+
(controller) => FunctionPrototypeCall(start, transformer, controller) :
142142
undefined;
143143
const transformAlgorithm = transform !== undefined ?
144144
createPromiseCallback('transformer.transform', transform, transformer) :
@@ -225,11 +225,11 @@ const nativeWritableGet =
225225
const namedGetters = {
226226
get readable() {
227227
if (!isTransformStream(this)) throw new ERR_INVALID_THIS('TransformStream');
228-
return ReflectApply(nativeReadableGet, this, []);
228+
return FunctionPrototypeCall(nativeReadableGet, this);
229229
},
230230
get writable() {
231231
if (!isTransformStream(this)) throw new ERR_INVALID_THIS('TransformStream');
232-
return ReflectApply(nativeWritableGet, this, []);
232+
return FunctionPrototypeCall(nativeWritableGet, this);
233233
},
234234
};
235235
const readableGetter =

lib/internal/webstreams/writablestream.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

33
const {
4+
FunctionPrototypeCall,
45
ObjectDefineProperties,
56
ObjectDefineProperty,
67
ObjectPrototypeIsPrototypeOf,
78
ObjectSetPrototypeOf,
8-
ReflectApply,
99
Symbol,
1010
SymbolToStringTag,
1111
} = primordials;
@@ -102,11 +102,11 @@ const isWritableStream = (value) =>
102102
const isWritableStreamDefaultWriter = (value) =>
103103
value != null &&
104104
ObjectPrototypeIsPrototypeOf(WritableStreamDefaultWriterNative.prototype,
105-
value);
105+
value);
106106
const isWritableStreamDefaultController = (value) =>
107107
value != null &&
108108
ObjectPrototypeIsPrototypeOf(WritableStreamDefaultControllerNative.prototype,
109-
value);
109+
value);
110110

111111
function isWritableStreamLocked(stream) {
112112
return stream.locked;
@@ -147,9 +147,9 @@ function newWritableStreamFromSink(sink, highWaterMark, sizeMode, sizeFn) {
147147
const close = sink?.close;
148148
const abort = sink?.abort;
149149
const startAlgorithm = start !== undefined ?
150-
(controller) => ReflectApply(start, sink, [controller]) :
150+
(controller) => FunctionPrototypeCall(start, sink, controller) :
151151
nonOpStart;
152-
// write is passed RAW (no per-call async wrapper): the native controller
152+
// Write is passed RAW (no per-call async wrapper): the native controller
153153
// calls it with `sink` as receiver and handles non-promise returns,
154154
// thenables, and synchronous throws itself.
155155
if (write !== undefined) validateFunction(write, 'sink.write');
@@ -167,6 +167,7 @@ function newWritableStreamFromSink(sink, highWaterMark, sizeMode, sizeFn) {
167167
/**
168168
* The public WritableStream interface. The returned object is the C++
169169
* WritableStream; all per-operation logic lives in C++.
170+
* @returns {WritableStream}
170171
*/
171172
function WritableStream(sink = kEmptyObject, strategy = kEmptyObject) {
172173
if (new.target === undefined)
@@ -305,6 +306,7 @@ ObjectDefineProperty(TransferredWritableStream, 'prototype', {
305306
/**
306307
* The public WritableStreamDefaultWriter interface. Acquiring a writer builds
307308
* the C++ writer (which locks the stream).
309+
* @returns {WritableStreamDefaultWriter}
308310
*/
309311
function WritableStreamDefaultWriter(stream) {
310312
if (new.target === undefined)

src/base_object_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace node {
1919
V(process_binding_data, process::BindingData) \
2020
V(timers_binding_data, timers::BindingData) \
2121
V(url_binding_data, url::BindingData) \
22-
V(modules_binding_data, modules::BindingData) \
22+
V(modules_binding_data, modules::BindingData) \
2323
V(webstreams_binding_data, webstreams::BindingData)
2424

2525
#define UNSERIALIZABLE_BINDING_TYPES(V) \

0 commit comments

Comments
 (0)