Skip to content

Commit

Permalink
zlib,stream: use “official” util.types typechecks
Browse files Browse the repository at this point in the history
The old variants have been deprecated since b20af80.

Refs: #18415

PR-URL: #19602
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and trivikr committed Mar 28, 2018
1 parent ff7c2cc commit e765257
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 6 additions & 7 deletions lib/stream.js
Expand Up @@ -38,16 +38,15 @@ Stream.Stream = Stream;

// Internal utilities
try {
Stream._isUint8Array = require('internal/util/types').isUint8Array;
} catch (e) {
// Throws for code outside of Node.js core.

try {
Stream._isUint8Array = process.binding('util').isUint8Array;
} catch (e) {
const types = require('util').types;
if (types && typeof types.isUint8Array === 'function') {
Stream._isUint8Array = types.isUint8Array;
} else {
// This throws for Node < 4.2.0 because there's no util binding and
// returns undefined for Node < 7.4.0.
Stream._isUint8Array = process.binding('util').isUint8Array;
}
} catch (e) {
}

if (!Stream._isUint8Array) {
Expand Down
10 changes: 7 additions & 3 deletions lib/zlib.js
Expand Up @@ -28,9 +28,13 @@ const {
ERR_ZLIB_INITIALIZATION_FAILED
} = require('internal/errors').codes;
const Transform = require('_stream_transform');
const { _extend } = require('util');
const { isAnyArrayBuffer } = process.binding('util');
const { isArrayBufferView } = require('internal/util/types');
const {
_extend,
types: {
isAnyArrayBuffer,
isArrayBufferView
}
} = require('util');
const binding = process.binding('zlib');
const assert = require('assert').ok;
const {
Expand Down

0 comments on commit e765257

Please sign in to comment.