]> zoso.dev Git - buffer.git/commitdiff
load old `buffer-browserify` in browsers that don't support Uint8Array
authorFeross Aboukhadijeh <feross@feross.org>
Mon, 18 Nov 2013 10:10:38 +0000 (02:10 -0800)
committerFeross Aboukhadijeh <feross@feross.org>
Mon, 18 Nov 2013 10:10:38 +0000 (02:10 -0800)
index.js

index f46a91a2131cee02eb1007e307cef169ac584dc4..fff48d2feb01bd32228b153b52339ef77ca0e235 100644 (file)
--- 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)