Init. Map does not function and only working on backend at the moment.
This commit is contained in:
29
node_modules/arraybuffer.slice/index.js
generated
vendored
Normal file
29
node_modules/arraybuffer.slice/index.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* An abstraction for slicing an arraybuffer even when
|
||||
* ArrayBuffer.prototype.slice is not supported
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(arraybuffer, start, end) {
|
||||
var bytes = arraybuffer.byteLength;
|
||||
start = start || 0;
|
||||
end = end || bytes;
|
||||
|
||||
if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
|
||||
|
||||
if (start < 0) { start += bytes; }
|
||||
if (end < 0) { end += bytes; }
|
||||
if (end > bytes) { end = bytes; }
|
||||
|
||||
if (start >= bytes || start >= end || bytes === 0) {
|
||||
return new ArrayBuffer(0);
|
||||
}
|
||||
|
||||
var abv = new Uint8Array(arraybuffer);
|
||||
var result = new Uint8Array(end - start);
|
||||
for (var i = start, ii = 0; i < end; i++, ii++) {
|
||||
result[ii] = abv[i];
|
||||
}
|
||||
return result.buffer;
|
||||
};
|
Reference in New Issue
Block a user