summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-03-17 16:59:54 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-04-10 00:36:26 +0200
commit49fd9c63d21c8c42a110996a6a68bf1fdcee12b4 (patch)
tree1ce3f7768a33e36ed6807f27d470407563f8275c /test
parentcc6abc6e84b96fd5f1c4123066eba93ddb637e60 (diff)
downloadandroid-node-v8-49fd9c63d21c8c42a110996a6a68bf1fdcee12b4.tar.gz
android-node-v8-49fd9c63d21c8c42a110996a6a68bf1fdcee12b4.tar.bz2
android-node-v8-49fd9c63d21c8c42a110996a6a68bf1fdcee12b4.zip
zlib: use `.bytesWritten` instead of `.bytesRead`
The introduction of `.bytesRead` to zlib streams was unfortunate, because other streams in Node.js core use the exact opposite naming of `.bytesRead` and `.bytesWritten`. While one could see how the original naming makes sense in a `Transform` stream context, we should try to work towards more consistent APIs in core for these things. This introduces `zlib.bytesWritten` and documentation-only deprecates `zlib.bytesRead`. PR-URL: https://github.com/nodejs/node/pull/19414 Refs: https://github.com/nodejs/node/issues/8874 Refs: https://github.com/nodejs/node/pull/13088 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-zlib-bytes-read.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/parallel/test-zlib-bytes-read.js b/test/parallel/test-zlib-bytes-read.js
index 6262c25149..493478e78d 100644
--- a/test/parallel/test-zlib-bytes-read.js
+++ b/test/parallel/test-zlib-bytes-read.js
@@ -33,13 +33,13 @@ for (const method of [
const comp = zlib[method[0]]();
comp.on('data', function(d) {
compData = Buffer.concat([compData, d]);
- assert.strictEqual(this.bytesRead, compWriter.size,
+ assert.strictEqual(this.bytesWritten, compWriter.size,
`Should get write size on ${method[0]} data.`);
});
comp.on('end', common.mustCall(function() {
- assert.strictEqual(this.bytesRead, compWriter.size,
+ assert.strictEqual(this.bytesWritten, compWriter.size,
`Should get write size on ${method[0]} end.`);
- assert.strictEqual(this.bytesRead, expectStr.length,
+ assert.strictEqual(this.bytesWritten, expectStr.length,
`Should get data size on ${method[0]} end.`);
{
@@ -49,12 +49,12 @@ for (const method of [
const decomp = zlib[method[1]]();
decomp.on('data', function(d) {
decompData = Buffer.concat([decompData, d]);
- assert.strictEqual(this.bytesRead, decompWriter.size,
+ assert.strictEqual(this.bytesWritten, decompWriter.size,
`Should get write size on ${method[0]}/` +
`${method[1]} data.`);
});
decomp.on('end', common.mustCall(function() {
- assert.strictEqual(this.bytesRead, compData.length,
+ assert.strictEqual(this.bytesWritten, compData.length,
`Should get compressed size on ${method[0]}/` +
`${method[1]} end.`);
assert.strictEqual(decompData.toString(), expectStr,
@@ -74,14 +74,16 @@ for (const method of [
const decomp = zlib[method[1]]();
decomp.on('data', function(d) {
decompData = Buffer.concat([decompData, d]);
- assert.strictEqual(this.bytesRead, decompWriter.size,
+ assert.strictEqual(this.bytesWritten, decompWriter.size,
`Should get write size on ${method[0]}/` +
`${method[1]} data.`);
});
decomp.on('end', common.mustCall(function() {
- assert.strictEqual(this.bytesRead, compData.length,
+ assert.strictEqual(this.bytesWritten, compData.length,
`Should get compressed size on ${method[0]}/` +
`${method[1]} end.`);
+ // Checking legacy name.
+ assert.strictEqual(this.bytesWritten, this.bytesRead);
assert.strictEqual(decompData.toString(), expectStr,
`Should get original string on ${method[0]}/` +
`${method[1]} end.`);