MCPcopy Create free account
hub / github.com/microsoft/SandDance / fromByteArray

Function fromByteArray

docs/app/js/sanddance-app.js:114161–114180  ·  view source on GitHub ↗
(uint8)

Source from the content-addressed store, hash-verified

114159 return output.join("");
114160}
114161function fromByteArray(uint8) {
114162 var tmp;
114163 var len3 = uint8.length;
114164 var extraBytes = len3 % 3 // if we have 1 byte left, pad 2 bytes
114165 ;
114166 var parts = [];
114167 var maxChunkLength = 16383 // must be multiple of 3
114168 ;
114169 // go through the array every three bytes, we'll deal with trailing stuff later
114170 for(var i3 = 0, len2 = len3 - extraBytes; i3 < len2; i3 += maxChunkLength)parts.push(encodeChunk(uint8, i3, i3 + maxChunkLength > len2 ? len2 : i3 + maxChunkLength));
114171 // pad the end with zeros, but make sure to not forget the extra bytes
114172 if (extraBytes === 1) {
114173 tmp = uint8[len3 - 1];
114174 parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + "==");
114175 } else if (extraBytes === 2) {
114176 tmp = (uint8[len3 - 2] << 8) + uint8[len3 - 1];
114177 parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + "=");
114178 }
114179 return parts.join("");
114180}
114181
114182},{}],"2wWVg":[function(require,module,exports) {
114183/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ exports.read = function(buffer, offset, isLE, mLen, nBytes) {

Callers

nothing calls this directly

Calls 1

encodeChunkFunction · 0.70

Tested by

no test coverage detected