From: Feross Aboukhadijeh Date: Mon, 18 Nov 2013 10:10:38 +0000 (-0800) Subject: load old `buffer-browserify` in browsers that don't support Uint8Array X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=5dc58e19fc8e60c798284db6e6af699e15fc69cf;p=buffer.git load old `buffer-browserify` in browsers that don't support Uint8Array --- 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)