MCPcopy Create free account
hub / github.com/TruthHun/BookStack / fromByteArray

Function fromByteArray

static/word2md/mammoth.browser.js:3995–4025  ·  view source on GitHub ↗
(uint8)

Source from the content-addressed store, hash-verified

3993}
3994
3995function fromByteArray (uint8) {
3996 var tmp
3997 var len = uint8.length
3998 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
3999 var output = ''
4000 var parts = []
4001 var maxChunkLength = 16383 // must be multiple of 3
4002
4003 // go through the array every three bytes, we'll deal with trailing stuff later
4004 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
4005 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
4006 }
4007
4008 // pad the end with zeros, but make sure to not forget the extra bytes
4009 if (extraBytes === 1) {
4010 tmp = uint8[len - 1]
4011 output += lookup[tmp >> 2]
4012 output += lookup[(tmp << 4) & 0x3F]
4013 output += '=='
4014 } else if (extraBytes === 2) {
4015 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
4016 output += lookup[tmp >> 10]
4017 output += lookup[(tmp >> 4) & 0x3F]
4018 output += lookup[(tmp << 2) & 0x3F]
4019 output += '='
4020 }
4021
4022 parts.push(output)
4023
4024 return parts.join('')
4025}
4026
4027},{}],40:[function(require,module,exports){
4028"use strict";

Callers

nothing calls this directly

Calls 1

encodeChunkFunction · 0.70

Tested by

no test coverage detected