From: Feross Aboukhadijeh Date: Thu, 9 Feb 2017 03:25:58 +0000 (-0800) Subject: remove 'typeof ArrayBuffer' checks X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=8ba284cd945629450dac9253e097223a2199d802;p=buffer.git remove 'typeof ArrayBuffer' checks Since buffer v5 we don't support browsers that lack typed arrays --- diff --git a/index.js b/index.js index c6bfc10..724d6f2 100644 --- a/index.js +++ b/index.js @@ -104,7 +104,7 @@ function from (value, encodingOrOffset, length) { throw new TypeError('"value" argument must not be a number') } - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + if (value instanceof ArrayBuffer) { return fromArrayBuffer(value, encodingOrOffset, length) } @@ -252,8 +252,7 @@ function fromObject (obj) { } if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { if (typeof obj.length !== 'number' || isnan(obj.length)) { return createBuffer(0) } @@ -365,8 +364,7 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) { return string.byteLength } if (typeof string !== 'string') {