From d91dbdc1be17f0a244c4d34731da0eef4fccd073 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Fri, 5 Apr 2024 12:42:35 +0300 Subject: [PATCH 1/3] stream: fix util.inspect for compression/decompressionStream --- lib/internal/webstreams/compression.js | 4 +- .../test-compression-decompression-stream.js | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-compression-decompression-stream.js diff --git a/lib/internal/webstreams/compression.js b/lib/internal/webstreams/compression.js index ac10d093dcefcc..2299b9c49e05bd 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -78,7 +78,7 @@ class CompressionStream { } [kInspect](depth, options) { - customInspect(depth, options, 'CompressionStream', { + return customInspect(depth, options, 'CompressionStream', { readable: this.#transform.readable, writable: this.#transform.writable, }); @@ -128,7 +128,7 @@ class DecompressionStream { } [kInspect](depth, options) { - customInspect(depth, options, 'DecompressionStream', { + return customInspect(depth, options, 'DecompressionStream', { readable: this.#transform.readable, writable: this.#transform.writable, }); diff --git a/test/parallel/test-compression-decompression-stream.js b/test/parallel/test-compression-decompression-stream.js new file mode 100644 index 00000000000000..69e7cc625f421e --- /dev/null +++ b/test/parallel/test-compression-decompression-stream.js @@ -0,0 +1,41 @@ +// Flags: --no-warnings --expose-internals +'use strict'; + +require('../common'); + +const assert = require('assert'); +const { describe, it } = require('node:test'); +const { + CompressionStream, + DecompressionStream, +} = require('stream/web'); + +const { + customInspectSymbol: kInspect, +} = require('internal/util'); + +describe('DecompressionStream kInspect method', () => { + it('should return a predictable inspection string with DecompressionStream', () => { + const decompressionStream = new DecompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = decompressionStream[kInspect](depth, options); + + assert(actual.includes('DecompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +}); + +describe('CompressionStream kInspect method', () => { + it('should return a predictable inspection string with CompressionStream', () => { + const compressionStream = new CompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = compressionStream[kInspect](depth, options); + + assert(actual.includes('CompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +}); From adea16aaf73d3891f6811ad32fe1f48c7fc8b221 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Fri, 10 May 2024 21:29:45 +0300 Subject: [PATCH 2/3] Update test-compression-decompression-stream.js Co-authored-by: Antoine du Hamel --- test/parallel/test-compression-decompression-stream.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-compression-decompression-stream.js b/test/parallel/test-compression-decompression-stream.js index 69e7cc625f421e..9914fc97c60c36 100644 --- a/test/parallel/test-compression-decompression-stream.js +++ b/test/parallel/test-compression-decompression-stream.js @@ -3,7 +3,7 @@ require('../common'); -const assert = require('assert'); +const assert = require('node:assert'); const { describe, it } = require('node:test'); const { CompressionStream, From 79c22bcf8c2c0124a1896928a8dd24e0b0718fbd Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Fri, 10 May 2024 21:29:50 +0300 Subject: [PATCH 3/3] Update test-compression-decompression-stream.js Co-authored-by: Antoine du Hamel --- test/parallel/test-compression-decompression-stream.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-compression-decompression-stream.js b/test/parallel/test-compression-decompression-stream.js index 9914fc97c60c36..1340c5c8bc44de 100644 --- a/test/parallel/test-compression-decompression-stream.js +++ b/test/parallel/test-compression-decompression-stream.js @@ -8,7 +8,7 @@ const { describe, it } = require('node:test'); const { CompressionStream, DecompressionStream, -} = require('stream/web'); +} = require('node:stream/web'); const { customInspectSymbol: kInspect,