You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 4, 2019. It is now read-only.
An updated version. Let me know what you think. There are a few notes/TODOs. I'm not entirely confident in it, but I'm sure that the delete call from before was not working as intended.
function concatenateBuffers() {
var byteLength = 0;
buffers.forEach(function(buffer) {
byteLength += buffer.byteLength;
// TODO(datermine): Figure out if this is necessary.
if (buffer.byteLength % 2 != 0) {
byteLength--;
}
});
var tmp = new Uint16Array(byteLength);
var lastOffset = 0;
buffers.forEach(function(buffer) {
// BYTES_PER_ELEMENT == 2 for Uint16Array
var bufferByteLength = buffer.byteLength;
if (bufferByteLength % 2 != 0) {
// NOTE(datermine): Uses to delete, now we use slice.
// delete buffer[bufferByteLength - 1];
buffer = buffer.slice(0, bufferByteLength - 1)
// NOTE(datermine): Once we slice instead of delete, this is really
// no longer necessary as it's the same as buffer.byteLength
bufferByteLength -= 1;
}
tmp.set(new Uint16Array(buffer), lastOffset);
// NOTE(datermine): We could just use buffer.byteLength here.
lastOffset += bufferByteLength;
});
var blob = new Blob([tmp.buffer], {
type: type
});
callback(blob);
}
The text was updated successfully, but these errors were encountered:
An updated version. Let me know what you think. There are a few notes/TODOs. I'm not entirely confident in it, but I'm sure that the delete call from before was not working as intended.
The text was updated successfully, but these errors were encountered: