diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-03-26 01:57:50 +0200 |
---|---|---|
committer | Trivikram <16024985+trivikr@users.noreply.github.com> | 2018-03-28 16:21:56 -0700 |
commit | e76525728301abdcab4638c14d20f04049576db3 (patch) | |
tree | 387c52d55a13f33edcda80d11d16b4a6a6a5d571 /lib/stream.js | |
parent | ff7c2ccf230d0fd43402229da38a238ea1ee039f (diff) | |
download | android-node-v8-e76525728301abdcab4638c14d20f04049576db3.tar.gz android-node-v8-e76525728301abdcab4638c14d20f04049576db3.tar.bz2 android-node-v8-e76525728301abdcab4638c14d20f04049576db3.zip |
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>
Diffstat (limited to 'lib/stream.js')
-rw-r--r-- | lib/stream.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/stream.js b/lib/stream.js index 9a816600a0..ba056026d8 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -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) { |