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

stream: simplify isUint8Array helper #29514

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 1 addition & 23 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

'use strict';

const { Object } = primordials;

const { Buffer } = require('buffer');
const pipeline = require('internal/streams/pipeline');
const eos = require('internal/streams/end-of-stream');
Expand All @@ -43,27 +41,7 @@ Stream.finished = eos;
// Backwards-compat with node 0.4.x
Stream.Stream = Stream;

// Internal utilities
try {
const types = require('internal/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.
// Please do not convert process.binding() to internalBinding() here.
// This is for compatibility with older versions when loaded as
// readable-stream.
Stream._isUint8Array = process.binding('util').isUint8Array;
}
} catch (e) { // eslint-disable-line no-unused-vars
}

if (!Stream._isUint8Array) {
Stream._isUint8Array = function _isUint8Array(obj) {
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
};
}
Stream._isUint8Array = require('internal/util/types').isUint8Array;

const version = process.version.substr(1).split('.');
if (version[0] === 0 && version[1] < 12) {
Expand Down