From 2d34cd049c239c91ed4409930944819abd175319 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 23 Oct 2014 21:18:19 +0900 Subject: [PATCH] jszip: adjust to match current API --- jszip/jszip.d.ts | 277 +++++++++++++++++++++++------------------------ 1 file changed, 137 insertions(+), 140 deletions(-) diff --git a/jszip/jszip.d.ts b/jszip/jszip.d.ts index 2f05895bd..399fcb9a3 100644 --- a/jszip/jszip.d.ts +++ b/jszip/jszip.d.ts @@ -3,155 +3,146 @@ // Definitions by: mzeiher // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module jszip { - export interface 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): JSZipFile; +interface 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; - /** - * Get files matching a RegExp from archive - * - * @param path RegExp to match - * @return Return all matching files or an empty array - */ - file(path: RegExp): JSZipFile[]; + /** + * Get files matching a RegExp from archive + * + * @param path RegExp to match + * @return Return all matching files or an empty array + */ + file(path: RegExp): JSZipObject[]; - /** - * Add a file to the archive - * - * @param path Relative path to file - * @param content Content of the file - * @param options Optional information about the file - * @return JSZip object - */ - file(path: string, content: any, options?: JSZipOptions): JSZip; + /** + * Add a file to the archive + * + * @param path Relative path to file + * @param content Content of the file + * @param options Optional information about the file + * @return JSZip object + */ + file(path: string, data: any, options?: JSZipFileOptions): JSZip; - /** - * Return 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; + /** + * Return 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; - /** - * Returns new JSZip instances with the matching folders as root - * - * @param name RegExp to match - * @return New array of JSZipFile objects which match the RegExp - */ - folder(name: RegExp): JSZipFile[]; + /** + * Returns new JSZip instances with the matching folders as root + * + * @param name RegExp to match + * @return New array of JSZipFile objects which match the RegExp + */ + folder(name: RegExp): 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; + /** + * Get all files wchich match the given filter function + * + * @param predicate Filter function + * @return Array of matched elements + */ + filter(predicate: (relativePath: string, file: JSZipObject) => boolean): JSZipObject[]; - /** - * Generates a new archive - * - * @param options Optional options for the generator - * @return The serialized archive - */ - generate(options?: JSZipGeneratorOptions): any; + /** + * 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; - /** - * Deserialize zip file - * - * @param data Serialized zip file - * @param options Options for deserializing - * @return Returns the JSZip instance - */ - load(data: any, options: JSZipOptions): JSZip; + /** + * Generates a new archive + * + * @param options Optional options for the generator + * @return The serialized archive + */ + generate(options?: JSZipGeneratorOptions): any; - /** - * Get all files wchich match the given filter function - * - * @param predicate Filter function - * @return Array of matched elements - */ - filter(predicate: (relativePath: string, file: JSZipFile) => boolean): JSZipFile[]; + /** + * Deserialize zip file + * + * @param data Serialized zip file + * @param options Options for deserializing + * @return Returns the JSZip instance + */ + load(data: any, options: JSZipLoadOptions): JSZip; +} - /** - * Calculate crc32 of given string - * - * @param data String to calculate crc32 from - * @param crc Optional: initializer for crc calc - * @return Calculated crc32 number - */ - crc32(data: string, crc?: number): number; +interface JSZipObject { + name: string; + data: any; + options: JSZipFileOptions; - /** - * Clone JSSZip instance - * - * @return Cloned instsance - */ - clone(): JSZip; + asText(): string; + asBinary(): string; + asArrayBuffer(): ArrayBuffer; + asUint8Array(): Uint8Array; + //asNodeBuffer(): Buffer; +} - /** - * UTF8 encode a string - * - * @param data String to encode - */ - utf8encode(data: string): string; +interface JSZipFileOptions { + base64?: boolean; + binary?: boolean; + date?: Date; + compression?: string; + comment?: string; + optimizedBinaryString?: boolean; + createFolders?: boolean; +} - /** - * UTF8 decode a string - * - * @param data String to decode - */ - utf8decode(data: string): string; +interface JSZipObjectOptions { + /** deprecated */ + base64: boolean; + /** deprecated */ + binary: boolean; + /** deprecated */ + dir: boolean; + /** deprecated */ + date: Date; + compression: string; +} - } +interface JSZipGeneratorOptions { + /** deprecated */ + base64?: boolean; + /** DEFLATE or STORE */ + compression?: string; + /** base64 (default), string, uint8array, blob */ + type?: string; + comment?: string; +} - export interface JSZipSupport { - arraybuffer: boolean; - uint8array: boolean; - blob: boolean; - } +interface JSZipLoadOptions { + base64?: boolean; + checkCRC32?: boolean; + optimizedBinaryString?: boolean; + createFolders?: boolean; +} - export interface JSZipGeneratorOptions { - base64?: boolean; //deprecated - compression: string; //DEFLATE or STORE - type: string; //base64 (default), string, uint8array, blob - } - - export interface JSZipOptions { - base64: boolean; - checkCRC32: boolean; - } - - export interface JSZipFile { - name: string; - data: any; - options: JSZipFileOptions; - - asText(): string; - asBinary(): any; - asArrayBuffer(): ArrayBuffer; - asUint8Array(): Uint8Array; - } - - export interface JSZipFileOptions { - base64: boolean; - binary: boolean; - dir: boolean; - date: Date; - } - - export interface JSZipBase64 { - } +interface JSZipSupport { + arraybuffer: boolean; + uint8array: boolean; + blob: boolean; + nodebuffer: boolean; } declare var JSZip: { + /** + * Create JSZip instance + */ + (): JSZip; /** * Create JSZip instance * If no parameters given an empty zip archive will be created @@ -159,15 +150,21 @@ declare var JSZip: { * @param data Serialized zip archive * @param options Description of the serialized zip archive */ - new (data?: any, options?: jszip.JSZipOptions): jszip.JSZip; + (data: any, options?: JSZipLoadOptions): JSZip; - prototype: jszip.JSZip; - support: jszip.JSZipSupport; -} + /** + * Create JSZip instance + */ + new (): JSZip; + /** + * Create JSZip instance + * If no parameters given an empty zip archive will be created + * + * @param data Serialized zip archive + * @param options Description of the serialized zip archive + */ + new (data: any, options?: JSZipLoadOptions): JSZip; -declare var JSZipBase64: { - encode(input: string, utf8?: any): string; - decode(input: string, utf8?: any): string; - - prototype: jszip.JSZipBase64; + prototype: JSZip; + support: JSZipSupport; } \ No newline at end of file