+var TA = require('typedarray')
+var xDataView = typeof DataView === 'undefined'
+ ? TA.DataView : DataView
+var xArrayBuffer = typeof ArrayBuffer === 'undefined'
+ ? TA.ArrayBuffer : ArrayBuffer
+var xUint8Array = typeof Uint8Array === 'undefined'
+ ? TA.Uint8Array : Uint8Array
+
exports.Buffer = Buffer
exports.SlowBuffer = Buffer
exports.INSPECT_MAX_BYTES = 50
else
throw new Error('First argument needs to be a number, array or string.')
- var buf = augment(new Uint8Array(length))
+ var buf = augment(new xUint8Array(length))
if (Buffer.isBuffer(subject)) {
// Speed optimization -- use set if we're copying from a Uint8Array
buf.set(subject)
* @return {boolean}
*/
function _browserSupport () {
- var arr = new Uint8Array(0)
+ var arr = new xUint8Array(0)
arr.foo = function () { return 42 }
try {
var B = require('../index.js').Buffer
var test = require('tape')
+var TA = require('typedarray')
+var xUint16Array = typeof Uint16Array === 'undefined'
+ ? TA.Uint16Array : Uint16Array
+var xUint8Array = typeof Uint8Array === 'undefined'
+ ? TA.Uint8Array : Uint8Array
test('new buffer from array', function (t) {
t.plan(1)
})
function arraybufferToString (arraybuffer) {
- return String.fromCharCode.apply(null, new Uint16Array(arraybuffer))
+ return String.fromCharCode.apply(null, new xUint16Array(arraybuffer))
}
test('buffer toArrayBuffer()', function (t) {
var data = [1, 2, 3, 4, 5, 6, 7, 8]
t.equal(
arraybufferToString(new B(data).toArrayBuffer()),
- arraybufferToString(new Uint8Array(data).buffer)
+ arraybufferToString(new xUint8Array(data).buffer)
)
t.end()
})