Skip to content

Commit

Permalink
zlib: remove zlib.bytesRead
Browse files Browse the repository at this point in the history
Use `zlib.bytesWritten` instead.

PR-URL: #55020
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
anonrig authored Sep 28, 2024
1 parent f805d0b commit e225f00
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 141 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,9 @@ core and obsoleted by the removal of NPN (Next Protocol Negotiation) support.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55020
description: End-of-Life.
- version: v11.0.0
pr-url: https://github.com/nodejs/node/pull/23308
description: Runtime deprecation.
Expand All @@ -2298,7 +2301,7 @@ changes:
description: Documentation-only deprecation.
-->

Type: Runtime
Type: End-of-Life

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
17 changes: 0 additions & 17 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -684,22 +684,6 @@ base class of the compressor/decompressor classes.
This class inherits from [`stream.Transform`][], allowing `node:zlib` objects to
be used in pipes and similar stream operations.

### `zlib.bytesRead`

<!-- YAML
added: v8.1.0
deprecated: v10.0.0
-->

> Stability: 0 - Deprecated: Use [`zlib.bytesWritten`][] instead.
* {number}

Deprecated alias for [`zlib.bytesWritten`][]. This original name was chosen
because it also made sense to interpret the value as the number of bytes
read by the engine, but is inconsistent with other streams in Node.js that
expose values under these names.

### `zlib.bytesWritten`

<!-- YAML
Expand Down Expand Up @@ -1307,7 +1291,6 @@ Decompress a chunk of data with [`Unzip`][].
[`buffer.kMaxLength`]: buffer.md#bufferkmaxlength
[`deflateInit2` and `inflateInit2`]: https://zlib.net/manual.html#Advanced
[`stream.Transform`]: stream.md#class-streamtransform
[`zlib.bytesWritten`]: #zlibbyteswritten
[convenience methods]: #convenience-methods
[zlib documentation]: https://zlib.net/manual.html#Constants
[zlib.createGzip example]: #zlib
21 changes: 0 additions & 21 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const {
genericNodeError,
} = require('internal/errors');
const { Transform, finished } = require('stream');
const {
deprecate,
} = require('internal/util');
const {
isArrayBufferView,
isAnyArrayBuffer,
Expand Down Expand Up @@ -271,24 +268,6 @@ ObjectDefineProperty(ZlibBase.prototype, '_closed', {
},
});

// `bytesRead` made sense as a name when looking from the zlib engine's
// perspective, but it is inconsistent with all other streams exposed by Node.js
// that have this concept, where it stands for the number of bytes read
// *from* the stream (that is, net.Socket/tls.Socket & file system streams).
ObjectDefineProperty(ZlibBase.prototype, 'bytesRead', {
__proto__: null,
configurable: true,
enumerable: true,
get: deprecate(function() {
return this.bytesWritten;
}, '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 ZlibBase
* @returns {void}
Expand Down
102 changes: 0 additions & 102 deletions test/parallel/test-zlib-bytes-read.js

This file was deleted.

0 comments on commit e225f00

Please sign in to comment.