Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: align @@toStringTag with other Web Streams implementations #45136

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/internal/webstreams/queuingstrategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ const countSizeFunction = ObjectDefineProperty(() => 1, 'name', nameDescriptor);
class ByteLengthQueuingStrategy {
[kType] = 'ByteLengthQueuingStrategy';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {{
* highWaterMark : number
Expand Down Expand Up @@ -110,6 +108,11 @@ class ByteLengthQueuingStrategy {
ObjectDefineProperties(ByteLengthQueuingStrategy.prototype, {
highWaterMark: kEnumerableProperty,
size: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ByteLengthQueuingStrategy',
},
});

/**
Expand Down Expand Up @@ -166,6 +169,11 @@ class CountQueuingStrategy {
ObjectDefineProperties(CountQueuingStrategy.prototype, {
highWaterMark: kEnumerableProperty,
size: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'CountQueuingStrategy',
},
});

module.exports = {
Expand Down
42 changes: 30 additions & 12 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ const kRelease = Symbol('kRelease');
class ReadableStream {
[kType] = 'ReadableStream';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {UnderlyingSource} [source]
* @param {QueuingStrategy} [strategy]
Expand Down Expand Up @@ -598,6 +596,11 @@ ObjectDefineProperties(ReadableStream.prototype, {
writable: true,
value: ReadableStream.prototype.values,
},
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableStream',
},
locked: kEnumerableProperty,
cancel: kEnumerableProperty,
getReader: kEnumerableProperty,
Expand Down Expand Up @@ -629,8 +632,6 @@ TransferredReadableStream.prototype[kDeserialize] = () => {};
class ReadableStreamBYOBRequest {
[kType] = 'ReadableStreamBYOBRequest';

get [SymbolToStringTag]() { return this[kType]; }

constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
Expand Down Expand Up @@ -710,6 +711,11 @@ ObjectDefineProperties(ReadableStreamBYOBRequest.prototype, {
view: kEnumerableProperty,
respond: kEnumerableProperty,
respondWithNewView: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableStreamBYOBRequest',
},
});

function createReadableStreamBYOBRequest(controller, view) {
Expand Down Expand Up @@ -769,8 +775,6 @@ class ReadIntoRequest {
class ReadableStreamDefaultReader {
[kType] = 'ReadableStreamDefaultReader';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {ReadableStream} stream
*/
Expand Down Expand Up @@ -854,13 +858,16 @@ ObjectDefineProperties(ReadableStreamDefaultReader.prototype, {
read: kEnumerableProperty,
releaseLock: kEnumerableProperty,
cancel: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableStreamDefaultReader',
},
});

class ReadableStreamBYOBReader {
[kType] = 'ReadableStreamBYOBReader';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {ReadableStream} stream
*/
Expand Down Expand Up @@ -971,13 +978,16 @@ ObjectDefineProperties(ReadableStreamBYOBReader.prototype, {
read: kEnumerableProperty,
releaseLock: kEnumerableProperty,
cancel: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableStreamBYOBReader',
},
});

class ReadableStreamDefaultController {
[kType] = 'ReadableStreamDefaultController';

get [SymbolToStringTag]() { return this[kType]; }

constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
Expand Down Expand Up @@ -1032,6 +1042,11 @@ ObjectDefineProperties(ReadableStreamDefaultController.prototype, {
close: kEnumerableProperty,
enqueue: kEnumerableProperty,
error: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableStreamDefaultController',
},
});

function createReadableStreamDefaultController() {
Expand All @@ -1048,8 +1063,6 @@ function createReadableStreamDefaultController() {
class ReadableByteStreamController {
[kType] = 'ReadableByteStreamController';

get [SymbolToStringTag]() { return this[kType]; }

constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
Expand Down Expand Up @@ -1168,6 +1181,11 @@ ObjectDefineProperties(ReadableByteStreamController.prototype, {
close: kEnumerableProperty,
enqueue: kEnumerableProperty,
error: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'ReadableByteStreamController',
},
});

function createReadableByteStreamController() {
Expand Down
14 changes: 10 additions & 4 deletions lib/internal/webstreams/transformstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ const assert = require('internal/assert');
class TransformStream {
[kType] = 'TransformStream';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {Transformer} [transformer]
* @param {QueuingStrategy} [writableStrategy]
Expand Down Expand Up @@ -236,6 +234,11 @@ class TransformStream {
ObjectDefineProperties(TransformStream.prototype, {
readable: kEnumerableProperty,
writable: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'TransformStream',
},
});

function TransferredTransformStream() {
Expand All @@ -261,8 +264,6 @@ TransferredTransformStream.prototype[kDeserialize] = () => {};
class TransformStreamDefaultController {
[kType] = 'TransformStreamDefaultController';

get [SymbolToStringTag]() { return this[kType]; }

constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
Expand Down Expand Up @@ -322,6 +323,11 @@ ObjectDefineProperties(TransformStreamDefaultController.prototype, {
enqueue: kEnumerableProperty,
error: kEnumerableProperty,
terminate: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'TransformStreamDefaultController',
},
});

function createTransformStreamDefaultController() {
Expand Down
21 changes: 15 additions & 6 deletions lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ const kError = Symbol('kError');
class WritableStream {
[kType] = 'WritableStream';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {UnderlyingSink} [sink]
* @param {QueuingStrategy} [strategy]
Expand Down Expand Up @@ -295,6 +293,11 @@ ObjectDefineProperties(WritableStream.prototype, {
abort: kEnumerableProperty,
close: kEnumerableProperty,
getWriter: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'WritableStream',
},
});

function TransferredWritableStream() {
Expand Down Expand Up @@ -348,8 +351,6 @@ TransferredWritableStream.prototype[kDeserialize] = () => {};
class WritableStreamDefaultWriter {
[kType] = 'WritableStreamDefaultWriter';

get [SymbolToStringTag]() { return this[kType]; }

/**
* @param {WritableStream} stream
*/
Expand Down Expand Up @@ -487,13 +488,16 @@ ObjectDefineProperties(WritableStreamDefaultWriter.prototype, {
close: kEnumerableProperty,
releaseLock: kEnumerableProperty,
write: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'WritableStreamDefaultWriter',
},
});

class WritableStreamDefaultController {
[kType] = 'WritableStreamDefaultController';

get [SymbolToStringTag]() { return this[kType]; }

constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
Expand Down Expand Up @@ -538,6 +542,11 @@ class WritableStreamDefaultController {
ObjectDefineProperties(WritableStreamDefaultController.prototype, {
signal: kEnumerableProperty,
error: kEnumerableProperty,
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: 'WritableStreamDefaultController',
},
});

function createWritableStreamDefaultController() {
Expand Down
61 changes: 61 additions & 0 deletions test/parallel/test-webstream-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

require('../common');

const assert = require('assert');

assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(WritableStream.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'WritableStream', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(WritableStreamDefaultWriter.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'WritableStreamDefaultWriter', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(WritableStreamDefaultController.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'WritableStreamDefaultController', writable: false },
);

assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableStream.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableStream', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableStreamBYOBRequest', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableStreamDefaultReader.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableStreamDefaultReader', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableStreamBYOBReader.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableStreamBYOBReader', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableStreamDefaultController.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableStreamDefaultController', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ReadableByteStreamController.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ReadableByteStreamController', writable: false },
);

assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'ByteLengthQueuingStrategy', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(CountQueuingStrategy.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'CountQueuingStrategy', writable: false },
);

assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(TransformStream.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'TransformStream', writable: false },
);
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(TransformStreamDefaultController.prototype, Symbol.toStringTag),
{ configurable: true, enumerable: false, value: 'TransformStreamDefaultController', writable: false },
);