|
|
@ -81,18 +81,16 @@ function encodeChunk (uint8, start, end) { |
|
|
|
} |
|
|
|
|
|
|
|
function fromByteArray (uint8) { |
|
|
|
var i |
|
|
|
var i, temp, len2 |
|
|
|
var len = uint8.length |
|
|
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
|
|
var output = '' |
|
|
|
var parts = [] |
|
|
|
var temp, length |
|
|
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
|
|
|
|
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
|
|
|
|
|
|
for (i = 0, length = len - extraBytes; i < length; i += maxChunkLength) { |
|
|
|
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > length ? length : (i + maxChunkLength))) |
|
|
|
for (i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { |
|
|
|
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) |
|
|
|
} |
|
|
|
|
|
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
|
|