var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))((function(resolve, reject) {
        function fulfilled(value) {
            try {
                step(generator.next(value));
            } catch (e) {
                reject(e);
            }
        }
        function rejected(value) {
            try {
                step(generator.throw(value));
            } catch (e) {
                reject(e);
            }
        }
        function step(result) {
            var value;
            result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P((function(resolve) {
                resolve(value);
            }))).then(fulfilled, rejected);
        }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    }));
};

import { saveAs } from "file-saver";

export function downloadCsv(str, name) {
    return __awaiter(this, void 0, void 0, (function*() {
        const blob = new Blob([ `\ufeff${str}` ], {
            type: "text/csv;charset=utf-8"
        });
        yield saveAs(blob, `${name}.csv`);
    }));
}

export function downloadExcel(arrayBuffer, name) {
    return __awaiter(this, void 0, void 0, (function*() {
        const blob = new Blob([ arrayBuffer ], {
            type: "application/octet-stream"
        });
        yield saveAs(blob, `${name}.xlsx`);
    }));
}

function workSheetStr2ArrayBuffer(workSheetStr) {
    const buffer = new ArrayBuffer(workSheetStr.length), arrayBuffer = new Uint8Array(buffer);
    for (let i = 0; i < workSheetStr.length; ++i) arrayBuffer[i] = 255 & workSheetStr.charCodeAt(i);
    return buffer;
}
//# sourceMappingURL=download.js.map
