From 5dc58e19fc8e60c798284db6e6af699e15fc69cf Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 18 Nov 2013 02:10:38 -0800 Subject: [PATCH] load old `buffer-browserify` in browsers that don't support Uint8Array --- index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index f46a91a..fff48d2 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,15 @@ var assert -exports.Buffer = Buffer -exports.SlowBuffer = Buffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 + +if (typeof Uint8Array === 'function') { + // Modern browser! + exports.Buffer = Buffer + exports.SlowBuffer = Buffer + exports.INSPECT_MAX_BYTES = 50 + Buffer.poolSize = 8192 +} else { + // Old browser :( + module.exports = require('buffer-browserify') +} // TODO: throw the correct exception type on errors (look at node source) -- 2.34.1