Skip to content

Class: ZipWriter ​

Constructors ​

Constructor ​

new ZipWriter(): ZipWriter

Returns ​

ZipWriter

Methods ​

add() ​

add(path, data, opts?): void

Add a package part.

Parameters ​

ParameterTypeDescription
pathstringfull zip path, e.g. ppt/slides/slide1.xml
datastring | Uint8Array<ArrayBufferLike>XML string (UTF-8 encoded) or already-decoded bytes (media)
opts?{ store?: boolean; }-
opts.store?booleanskip DEFLATE for this entry (already-compressed media)

Returns ​

void


entries() ​

entries(): object[]

Snapshot the accumulated entries in insertion order, before zipping. Each entry carries its already-encoded bytes and whether it was added with store (recovered from the per-entry level). This is the seam the package-parts path reads: the same accumulator generate would zip, exposed without running DEFLATE. Every value in #entries is the [bytes, opts] tuple add writes, so the cast is total.

Returns ​

object[]


generate() ​

generate(type, opts): Promise<string | ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob>

Finalize the archive in the requested output shape.

Parameters ​

ParameterTypeDescription
type"arraybuffer" | "blob" | "base64" | "binarystring" | "nodebuffer" | "uint8array"one of the supported ZIP_OUTPUT_TYPE output shapes
opts{ compression: boolean; }-
opts.compressionbooleanfalse stores every entry uncompressed

Returns ​

Promise<string | ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob>


toBytes() ​

toBytes(compression?): Uint8Array

Compress all accumulated entries to raw zip bytes.

Parameters ​

ParameterTypeDefault valueDescription
compressionbooleantruefalse stores every entry uncompressed (level 0)

Returns ​

Uint8Array