2 * An abstraction for slicing an arraybuffer even when
3 * ArrayBuffer.prototype.slice is not supported
8 module.exports = function(arraybuffer, start, end) {
9 var bytes = arraybuffer.byteLength;
13 if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
15 if (start < 0) { start += bytes; }
16 if (end < 0) { end += bytes; }
17 if (end > bytes) { end = bytes; }
19 if (start >= bytes || start >= end || bytes === 0) {
20 return new ArrayBuffer(0);
23 var abv = new Uint8Array(arraybuffer);
24 var result = new Uint8Array(end - start);
25 for (var i = start, ii = 0; i < end; i++, ii++) {