UNPKG

docxml

Version:

TypeScript (component) library for building and parsing a DOCX file

92 lines (91 loc) 2.91 kB
import { WalkOptions } from "../../std@0.116.0/fs/walk.js"; import type { InputFileFormat, JSZipFileOptions, JSZipGeneratorOptions, JSZipLoadOptions, JSZipObject, OutputByType } from "./types.js"; /** * Read zip file asynchronously from a file * * @param path of zip file * @return Returns promise */ export declare function readZip(path: string): Promise<JSZip>; /** * Read a directory as a JSZip * * @param dir directory * @return Returns promise */ export declare function zipDir(dir: string, options?: WalkOptions): Promise<JSZip>; export declare class JSZip { protected _z: any; constructor(z?: any); /** * Returns an new JSZip instance with the given folder as root * * @param name Name of the folder * @return New JSZip object with the given folder as root or null */ folder(name: string): JSZip; /** * Get a file from the archive * * @param Path relative path to file * @return File matching path, null if no file found */ file(path: string): JSZipObject; /** * Add a file to the archive * * @param path Relative path to file * @param data Content of the file * @param options Optional information about the file * @return JSZip object */ addFile(path: string, content?: string | Uint8Array, options?: JSZipFileOptions): JSZipObject; files(): { [key: string]: JSZipObject; }; /** * Generates a new archive asynchronously * * @param options Optional options for the generator * @param onUpdate The optional function called on each internal update with the metadata. * @return The serialized archive */ generateAsync<T extends keyof OutputByType>(options?: JSZipGeneratorOptions<T>): Promise<OutputByType[T]>; /** * Get all files which match the given filter function * * @param predicate Filter function * @return Array of matched elements */ filter(predicate: (relativePath: string, file: JSZipObject) => boolean): JSZipObject[]; /** * Removes the file or folder from the archive * * @param path Relative path of file or folder * @return Returns the JSZip instance */ remove(path: string): JSZip; /** * Load zip data * * @param data Serialized zip file * @param options Options for deserializing * @return Returns promise of self */ loadAsync(data: InputFileFormat, options?: JSZipLoadOptions): Promise<JSZip>; /** * Write zip file asynchronously to a file * * @param path of zip file * @return Returns promise */ writeZip(path: string): Promise<void>; /** * Unzip a JSZip asynchronously to a directory * * @param dir to unzip into * @return Returns promise */ unzip(dir?: string): Promise<void>; [Symbol.iterator](): Iterator<JSZipObject>; }