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 Sep 21, 2024
1 parent 4573231 commit 9686153
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 @@ -94,7 +94,7 @@ class CompressionStream {
[kInspect](depth, options) {
if (!isCompressionStream(this))
throw new ERR_INVALID_THIS('CompressionStream');
customInspect(depth, options, 'CompressionStream', {
return customInspect(depth, options, 'CompressionStream', {
readable: this[kTransform].readable,
writable: this[kTransform].writable,
});
Expand Down Expand Up @@ -146,7 +146,7 @@ class DecompressionStream {
[kInspect](depth, options) {
if (!isDecompressionStream(this))
throw new ERR_INVALID_THIS('DecompressionStream');
customInspect(depth, options, 'DecompressionStream', {
return customInspect(depth, options, 'DecompressionStream', {
readable: this[kTransform].readable,
writable: this[kTransform].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 9686153

Please sign in to comment.