Skip to content

Commit

Permalink
stream: fix util.inspect for compression/decompressionStream
Browse files Browse the repository at this point in the history
PR-URL: #52283
Fixes: #52263
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Deokjin Kim <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
mertcanaltin authored and targos committed May 12, 2024
1 parent c0000f4 commit fa71543
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/webstreams/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
});
Expand Down
41 changes: 41 additions & 0 deletions test/parallel/test-compression-decompression-stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Flags: --no-warnings --expose-internals
'use strict';

require('../common');

const assert = require('node:assert');
const { describe, it } = require('node:test');
const {
CompressionStream,
DecompressionStream,
} = require('node: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'));
});
});

0 comments on commit fa71543

Please sign in to comment.