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 <luigipinca@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • 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.