(uint8)
| 8567 | } |
| 8568 | |
| 8569 | function fromByteArray (uint8) { |
| 8570 | if (!inited) { |
| 8571 | init(); |
| 8572 | } |
| 8573 | var tmp; |
| 8574 | var len = uint8.length; |
| 8575 | var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes |
| 8576 | var output = ''; |
| 8577 | var parts = []; |
| 8578 | var maxChunkLength = 16383; // must be multiple of 3 |
| 8579 | |
| 8580 | // go through the array every three bytes, we'll deal with trailing stuff later |
| 8581 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { |
| 8582 | parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))); |
| 8583 | } |
| 8584 | |
| 8585 | // pad the end with zeros, but make sure to not forget the extra bytes |
| 8586 | if (extraBytes === 1) { |
| 8587 | tmp = uint8[len - 1]; |
| 8588 | output += lookup[tmp >> 2]; |
| 8589 | output += lookup[(tmp << 4) & 0x3F]; |
| 8590 | output += '=='; |
| 8591 | } else if (extraBytes === 2) { |
| 8592 | tmp = (uint8[len - 2] << 8) + (uint8[len - 1]); |
| 8593 | output += lookup[tmp >> 10]; |
| 8594 | output += lookup[(tmp >> 4) & 0x3F]; |
| 8595 | output += lookup[(tmp << 2) & 0x3F]; |
| 8596 | output += '='; |
| 8597 | } |
| 8598 | |
| 8599 | parts.push(output); |
| 8600 | |
| 8601 | return parts.join('') |
| 8602 | } |
| 8603 | |
| 8604 | function read (buffer, offset, isLE, mLen, nBytes) { |
| 8605 | var e, m; |
no test coverage detected