zlib,stream: use “official” util.types typechecks
The old variants have been deprecated since b20af8088a4d5cccb19. Refs: https://github.com/nodejs/node/pull/18415 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
ff7c2ccf23
commit
e765257283
@ -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) {
|
||||
|
10
lib/zlib.js
10
lib/zlib.js
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user