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
|
// Internal utilities
|
||||||
try {
|
try {
|
||||||
Stream._isUint8Array = require('internal/util/types').isUint8Array;
|
const types = require('util').types;
|
||||||
} catch (e) {
|
if (types && typeof types.isUint8Array === 'function') {
|
||||||
// Throws for code outside of Node.js core.
|
Stream._isUint8Array = types.isUint8Array;
|
||||||
|
} else {
|
||||||
try {
|
|
||||||
Stream._isUint8Array = process.binding('util').isUint8Array;
|
|
||||||
} catch (e) {
|
|
||||||
// This throws for Node < 4.2.0 because there's no util binding and
|
// This throws for Node < 4.2.0 because there's no util binding and
|
||||||
// returns undefined for Node < 7.4.0.
|
// returns undefined for Node < 7.4.0.
|
||||||
|
Stream._isUint8Array = process.binding('util').isUint8Array;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Stream._isUint8Array) {
|
if (!Stream._isUint8Array) {
|
||||||
|
10
lib/zlib.js
10
lib/zlib.js
@ -28,9 +28,13 @@ const {
|
|||||||
ERR_ZLIB_INITIALIZATION_FAILED
|
ERR_ZLIB_INITIALIZATION_FAILED
|
||||||
} = require('internal/errors').codes;
|
} = require('internal/errors').codes;
|
||||||
const Transform = require('_stream_transform');
|
const Transform = require('_stream_transform');
|
||||||
const { _extend } = require('util');
|
const {
|
||||||
const { isAnyArrayBuffer } = process.binding('util');
|
_extend,
|
||||||
const { isArrayBufferView } = require('internal/util/types');
|
types: {
|
||||||
|
isAnyArrayBuffer,
|
||||||
|
isArrayBufferView
|
||||||
|
}
|
||||||
|
} = require('util');
|
||||||
const binding = process.binding('zlib');
|
const binding = process.binding('zlib');
|
||||||
const assert = require('assert').ok;
|
const assert = require('assert').ok;
|
||||||
const {
|
const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user