From 4cf155ca0c92bd02733de4c30c5d1d6e36e95b27 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 13 Nov 2023 13:47:46 +0100 Subject: [PATCH] stream: add Symbol.toStringTag to Compression Streams PR-URL: https://github.com/nodejs/node/pull/50712 Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina --- lib/internal/webstreams/compression.js | 11 +++++++++++ test/parallel/test-whatwg-webstreams-compression.js | 3 +++ 2 files changed, 14 insertions(+) diff --git a/lib/internal/webstreams/compression.js b/lib/internal/webstreams/compression.js index 2ba8e53fa28e73..cda3c4b08f3b5b 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -2,6 +2,7 @@ const { ObjectDefineProperties, + SymbolToStringTag, Symbol, } = primordials; @@ -149,11 +150,21 @@ class DecompressionStream { ObjectDefineProperties(CompressionStream.prototype, { readable: kEnumerableProperty, writable: kEnumerableProperty, + [SymbolToStringTag]: { + __proto__: null, + configurable: true, + value: 'CompressionStream', + }, }); ObjectDefineProperties(DecompressionStream.prototype, { readable: kEnumerableProperty, writable: kEnumerableProperty, + [SymbolToStringTag]: { + __proto__: null, + configurable: true, + value: 'DecompressionStream', + }, }); module.exports = { diff --git a/test/parallel/test-whatwg-webstreams-compression.js b/test/parallel/test-whatwg-webstreams-compression.js index 859df4e07bed88..f9ae8d87265b58 100644 --- a/test/parallel/test-whatwg-webstreams-compression.js +++ b/test/parallel/test-whatwg-webstreams-compression.js @@ -15,6 +15,9 @@ async function test(format) { const gzip = new CompressionStream(format); const gunzip = new DecompressionStream(format); + assert.strictEqual(gzip[Symbol.toStringTag], 'CompressionStream'); + assert.strictEqual(gunzip[Symbol.toStringTag], 'DecompressionStream'); + gzip.readable.pipeTo(gunzip.writable).then(common.mustCall()); const reader = gunzip.readable.getReader();