Skip to content

Instantly share code, notes, and snippets.

@nahidakbar
Created October 27, 2014 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahidakbar/d2248dbb2c8411e03034 to your computer and use it in GitHub Desktop.
Save nahidakbar/d2248dbb2c8411e03034 to your computer and use it in GitHub Desktop.
function Uint8ArrayListWriter(contentSize, filename)
{
var output, that = this, offset, errored;
function init(callback)
{
output = [];
offset = 0;
errored = false;
callback();
}
function writeUint8Array(array, callback)
{
if (!errored)
{
if (array.length)
{
output.push(array);
offset += array.length;
} else
{
showError(filename + ' decompresstion error. Content will be trimmed to current position. All elements may not work as expected as a result.');
errored = true;
output = output.subarray(0, offset);
}
}
callback();
}
function getData(callback)
{
output.totalLength = offset;
callback(output);
}
that.init = init;
that.writeUint8Array = writeUint8Array;
that.getData = getData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment