From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 07:10:21 +0000 (-0800) Subject: Drop Node 0.10 support X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=92cbbd2b2e9297e171805fa9b04d4fa35025f66b;p=buffer.git Drop Node 0.10 support Fix https://github.com/feross/buffer/issues/184 --- 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 }