Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- doc: do not use Unicode multiplication sign
- doc: fix incorrect parameter name
- zlib: remove `instanceof Buffer`
- zlib: stylistic change
- test: remove unneeded array spread
- test: stylistic change
  • Loading branch information
TimothyGu committed Mar 30, 2017
1 parent 874377b commit 0a41bf0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ ignored by the decompression classes.

* `flush` {integer} (default: `zlib.constants.Z_NO_FLUSH`)
* `finishFlush` {integer} (default: `zlib.constants.Z_FINISH`)
* `chunkSize` {integer} (default: 16 × 1024)
* `chunkSize` {integer} (default: 16\*1024)
* `windowBits` {integer}
* `level` {integer} (compression only)
* `memLevel` {integer} (compression only)
Expand Down Expand Up @@ -627,7 +627,7 @@ changes:
description: The `buffer` parameter can be an Uint8Array now.
-->

- `buf` {Buffer|Uint8Array|string}
- `buffer` {Buffer|Uint8Array|string}

Decompress a chunk of data with [Unzip][].

Expand Down
4 changes: 2 additions & 2 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function zlibBuffer(engine, buffer, callback) {
// Streams do not support non-Buffer Uint8Arrays yet. Convert it to a
// Buffer without copying.
if (isUint8Array(buffer) &&
!(Object.getPrototypeOf(buffer) === Buffer.prototype ||
buffer instanceof Buffer))
Object.getPrototypeOf(buffer) !== Buffer.prototype) {
buffer = Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
}

var buffers = [];
var nread = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-convenience-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const zlib = require('zlib');

const expectStr = 'blahblahblahblahblahblah';
const expectBuf = Buffer.from(expectStr);
const expectUint8Array = new Uint8Array([...expectBuf]);
const expectUint8Array = new Uint8Array(expectBuf);
const opts = {
level: 9,
chunkSize: 1024,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const spdyDict = Buffer.from([
'ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1',
'.1statusversionurl\0'
].join(''));
const spdyDictUint8Array = new Uint8Array([...spdyDict]);
const spdyDictUint8Array = new Uint8Array(spdyDict);

const input = [
'HTTP/1.1 200 Ok',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-not-string-or-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const assert = require('assert');
const zlib = require('zlib');

const expected =
/^TypeError: "buffer" argument must be a string, Buffer, or Uint8Array$/;
/^TypeError: "buffer" argument must be a string, Buffer, or Uint8Array$/;

assert.throws(() => { zlib.deflateSync(undefined); }, expected);
assert.throws(() => { zlib.deflateSync(null); }, expected);
Expand Down

0 comments on commit 0a41bf0

Please sign in to comment.