From: elliottcable Date: Wed, 22 May 2013 18:02:08 +0000 (-0300) Subject: No longer using ES5 Array.isArray(), to support IE6 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=2db5a78f02e25aac6f9967ba3a127f0f0e32b212;p=buffer.git No longer using ES5 Array.isArray(), to support IE6 --- diff --git a/index.js b/index.js index a4bf90c..c1f9c6b 100644 --- a/index.js +++ b/index.js @@ -385,7 +385,7 @@ Buffer.isBuffer = function isBuffer(b) { }; Buffer.concat = function (list, totalLength) { - if (!Array.isArray(list)) { + if (!isArray(list)) { throw new Error("Usage: Buffer.concat(list, [totalLength])\n \ list should be an Array."); } @@ -424,8 +424,16 @@ function coerce(length) { return length < 0 ? 0 : length; } +function isArray(subject) { + return (Array.isArray || + function(subject){ + return {}.toString.apply(subject) == '[object Array]' + }) + (subject) +} + function isArrayIsh(subject) { - return Array.isArray(subject) || Buffer.isBuffer(subject) || + return isArray(subject) || Buffer.isBuffer(subject) || subject && typeof subject === 'object' && typeof subject.length === 'number'; }