From 92cbbd2b2e9297e171805fa9b04d4fa35025f66b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 15 Feb 2018 23:10:21 -0800 Subject: [PATCH] Drop Node 0.10 support Fix https://github.com/feross/buffer/issues/184 --- index.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 19a9978..8ea2326 100644 --- a/index.js +++ b/index.js @@ -270,7 +270,7 @@ function fromObject (obj) { } if (obj) { - if (isArrayBufferView(obj) || 'length' in obj) { + if (ArrayBuffer.isView(obj) || 'length' in obj) { if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { return createBuffer(0) } @@ -369,7 +369,7 @@ Buffer.concat = function concat (list, length) { var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] - if (isArrayBufferView(buf)) { + if (ArrayBuffer.isView(buf)) { buf = Buffer.from(buf) } if (!Buffer.isBuffer(buf)) { @@ -385,7 +385,7 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (isArrayBufferView(string) || isArrayBuffer(string)) { + if (ArrayBuffer.isView(string) || isArrayBuffer(string)) { return string.byteLength } if (typeof string !== 'string') { @@ -1731,11 +1731,6 @@ function isArrayBuffer (obj) { typeof obj.byteLength === 'number') } -// Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView` -function isArrayBufferView (obj) { - return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj) -} - function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -- 2.34.1