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 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.