Created
October 27, 2014 01:49
-
-
Save nahidakbar/d2248dbb2c8411e03034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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