Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: move bytesRead accessors to runtime deprecation #23308

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2056,12 +2056,15 @@ core and obsoleted by the removal of NPN (Next Protocol Negotiation) support.
### DEP0108: zlib.bytesRead
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/REPLACEME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REPLACEME -> 23308

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done!

description: Runtime deprecation.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/19414
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

Deprecated alias for [`zlib.bytesWritten`][]. This original name was chosen
because it also made sense to interpret the value as the number of bytes
Expand Down
11 changes: 7 additions & 4 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
} = require('internal/errors').codes;
const Transform = require('_stream_transform');
const {
deprecate,
_extend,
inherits,
types: {
Expand Down Expand Up @@ -333,12 +334,14 @@ Object.defineProperty(Zlib.prototype, '_closed', {
Object.defineProperty(Zlib.prototype, 'bytesRead', {
configurable: true,
enumerable: true,
get() {
get: deprecate(function() {
return this.bytesWritten;
},
set(value) {
}, 'zlib.bytesRead is deprecated and will change its meaning in the ' +
'future. Use zlib.bytesWritten instead.', 'DEP0108'),
set: deprecate(function(value) {
this.bytesWritten = value;
}
}, 'Setting zlib.bytesRead is deprecated. ' +
'This feature will be removed in the future.', 'DEP0108')
});

// This callback is used by `.params()` to wait until a full flush happened
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-zlib-bytes-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ function createWriter(target, buffer) {
return writer;
}

common.expectWarning(
'DeprecationWarning',
'zlib.bytesRead is deprecated and will change its meaning in the ' +
'future. Use zlib.bytesWritten instead.',
'DEP0108');

for (const method of [
['createGzip', 'createGunzip', false],
['createGzip', 'createUnzip', false],
Expand Down