@ -37,6 +37,14 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#toString()", () => {
|
||||||
|
it("should return a non-empty string", async () => {
|
||||||
|
const result = await Packer.toString(file);
|
||||||
|
|
||||||
|
assert.isAbove(result.length, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#toBuffer()", () => {
|
describe("#toBuffer()", () => {
|
||||||
it("should create a standard docx file", async function () {
|
it("should create a standard docx file", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
|
@ -13,6 +13,17 @@ export enum PrettifyType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Packer {
|
export class Packer {
|
||||||
|
public static async toString(file: File, prettify?: boolean | PrettifyType): Promise<string> {
|
||||||
|
const zip = this.compiler.compile(file, prettify);
|
||||||
|
const zipData = await zip.generateAsync({
|
||||||
|
type: "string",
|
||||||
|
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
compression: "DEFLATE",
|
||||||
|
});
|
||||||
|
|
||||||
|
return zipData;
|
||||||
|
}
|
||||||
|
|
||||||
public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise<Buffer> {
|
public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise<Buffer> {
|
||||||
const zip = this.compiler.compile(file, prettify);
|
const zip = this.compiler.compile(file, prettify);
|
||||||
const zipData = await zip.generateAsync({
|
const zipData = await zip.generateAsync({
|
||||||
|
Reference in New Issue
Block a user