1 |
|
2 |
|
3 | import { __awaiter, __generator } from "tslib";
|
4 | import { gunzip, strFromU8 } from 'fflate';
|
5 | export var convert = function (stream) { return __awaiter(void 0, void 0, void 0, function () {
|
6 | return __generator(this, function (_a) {
|
7 | if (stream instanceof Blob || stream instanceof ReadableStream) {
|
8 | return [2 , new Response(stream)
|
9 | .arrayBuffer()
|
10 | .then(function (buffer) { return new Uint8Array(buffer); })];
|
11 | }
|
12 | else {
|
13 | return [2 , Promise.reject('Invalid content type')];
|
14 | }
|
15 | return [2 ];
|
16 | });
|
17 | }); };
|
18 | export var base64ToArrayBuffer = function (base64) {
|
19 | return Uint8Array.from(window.atob(base64), function (c) { return c.charCodeAt(0); });
|
20 | };
|
21 | export var gzipDecompressToString = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
22 | return __generator(this, function (_a) {
|
23 | switch (_a.label) {
|
24 | case 0: return [4 , new Promise(function (resolve, reject) {
|
25 | gunzip(data, function (err, resp) {
|
26 | if (err)
|
27 | reject(err);
|
28 | else
|
29 | resolve(strFromU8(resp));
|
30 | });
|
31 | })];
|
32 | case 1: return [2 , _a.sent()];
|
33 | }
|
34 | });
|
35 | }); };
|
36 |
|
\ | No newline at end of file |