MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / fromByteArray$1

Function fromByteArray$1

misc/test-browser/mocha.js:812–845  ·  view source on GitHub ↗
(uint8)

Source from the content-addressed store, hash-verified

810 }
811
812 function fromByteArray$1 (uint8) {
813 if (!inited$1) {
814 init$1();
815 }
816 var tmp;
817 var len = uint8.length;
818 var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
819 var output = '';
820 var parts = [];
821 var maxChunkLength = 16383; // must be multiple of 3
822
823 // go through the array every three bytes, we'll deal with trailing stuff later
824 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
825 parts.push(encodeChunk$1(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
826 }
827
828 // pad the end with zeros, but make sure to not forget the extra bytes
829 if (extraBytes === 1) {
830 tmp = uint8[len - 1];
831 output += lookup$1[tmp >> 2];
832 output += lookup$1[(tmp << 4) & 0x3F];
833 output += '==';
834 } else if (extraBytes === 2) {
835 tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
836 output += lookup$1[tmp >> 10];
837 output += lookup$1[(tmp >> 4) & 0x3F];
838 output += lookup$1[(tmp << 2) & 0x3F];
839 output += '=';
840 }
841
842 parts.push(output);
843
844 return parts.join('')
845 }
846
847 function read$1 (buffer, offset, isLE, mLen, nBytes) {
848 var e, m;

Callers 1

base64Slice$1Function · 0.85

Calls 3

init$1Function · 0.85
encodeChunk$1Function · 0.85
joinMethod · 0.45

Tested by

no test coverage detected