(input: Uint8Array)
| 514 | } |
| 515 | |
| 516 | private _array2base64(input: Uint8Array): string { |
| 517 | const byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
| 518 | |
| 519 | const output = []; |
| 520 | |
| 521 | for (let i = 0; i < input.length; i += 3) { |
| 522 | const byte1 = input[i]; |
| 523 | const haveByte2 = i + 1 < input.length; |
| 524 | const byte2 = haveByte2 ? input[i + 1] : 0; |
| 525 | const haveByte3 = i + 2 < input.length; |
| 526 | const byte3 = haveByte3 ? input[i + 2] : 0; |
| 527 | |
| 528 | const outByte1 = byte1 >> 2; |
| 529 | const outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); |
| 530 | let outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); |
| 531 | let outByte4 = byte3 & 0x3f; |
| 532 | |
| 533 | if (!haveByte3) { |
| 534 | outByte4 = 64; |
| 535 | |
| 536 | if (!haveByte2) { |
| 537 | outByte3 = 64; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]); |
| 542 | } |
| 543 | |
| 544 | return output.join(''); |
| 545 | } |
| 546 | |
| 547 | private _read(blob, kind) { |
| 548 | if (!(blob instanceof Blob)) { |
no test coverage detected