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,stream: use “official” util.types typechecks #19602

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 6 additions & 7 deletions lib/stream.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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