From 0b51d137b56a3aa9367312ee15009611f10b5641 Mon Sep 17 00:00:00 2001 From: RaulTsc Date: Sun, 3 Jan 2016 00:31:24 +0200 Subject: [PATCH] Removed Buffer.toArrayBuffer(). Fixes #90 --- index.js | 21 --------------------- test/static.js | 14 -------------- 2 files changed, 35 deletions(-) diff --git a/index.js b/index.js index 0dc9007..76bfbbe 100644 --- a/index.js +++ b/index.js @@ -1315,26 +1315,6 @@ Buffer.prototype.fill = function fill (value, start, end) { return this } -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } -} - // HELPER FUNCTIONS // ================ @@ -1401,7 +1381,6 @@ Buffer._augment = function _augment (arr) { arr.writeDoubleBE = BP.writeDoubleBE arr.fill = BP.fill arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer return arr } diff --git a/test/static.js b/test/static.js index 68faa00..4de900b 100644 --- a/test/static.js +++ b/test/static.js @@ -15,17 +15,3 @@ test('Buffer.isBuffer', function (t) { t.equal(B.isBuffer('hey'), false) t.end() }) - -test('Buffer.toArrayBuffer', function (t) { - var data = [1, 2, 3, 4, 5, 6, 7, 8] - if (typeof Uint8Array !== 'undefined') { - var result = new B(data).toArrayBuffer() - var expected = new Uint8Array(data).buffer - for (var i = 0; i < expected.byteLength; i++) { - t.equal(result[i], expected[i]) - } - } else { - t.pass('No toArrayBuffer() method provided in old browsers') - } - t.end() -}) -- 2.34.1