From 2db5a78f02e25aac6f9967ba3a127f0f0e32b212 Mon Sep 17 00:00:00 2001 From: elliottcable Date: Wed, 22 May 2013 15:02:08 -0300 Subject: [PATCH] No longer using ES5 Array.isArray(), to support IE6 --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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'; } -- 2.34.1