jszip
- Version 3.10.1
- Published
- 762 kB
- 4 dependencies
- (MIT OR GPL-3.0-or-later) license
Install
npm i jszipyarn add jszippnpm add jszipOverview
Create, read and edit .zip files with JavaScript http://stuartk.com/jszip
Index
Variables
Interfaces
Type Aliases
Variables
variable JSZip
var JSZip: JSZip;Interfaces
interface JSZip
interface JSZip {}property external
external: {    Promise: PromiseConstructorLike;};property files
files: { [key: string]: JSZip.JSZipObject };property prototype
prototype: JSZip;property support
support: JSZipSupport;property version
version: string;method file
file: {    (path: string): JSZip.JSZipObject | null;    (path: RegExp): JSZip.JSZipObject[];    <T extends keyof InputByType>(        path: string,        data: InputByType[T] | Promise<InputByType[T]>,        options?: JSZip.JSZipFileOptions    ): this;    <T extends keyof InputByType>(        path: string,        data: null,        options?: JSZip.JSZipFileOptions & { dir: true }    ): this;};- Get a file from the archive - Parameter Path- relative path to file File matching path, null if no file found 
- Get files matching a RegExp from archive - Parameter path- RegExp to match Return all matching files or an empty array 
- Add a file to the archive - Parameter path- Relative path to file - Parameter data- Content of the file - Parameter options- Optional information about the file JSZip object 
method filter
filter: (    predicate: (relativePath: string, file: JSZip.JSZipObject) => boolean) => JSZip.JSZipObject[];- Get all files which match the given filter function - Parameter predicate- Filter function Array of matched elements 
method folder
folder: { (name: string): JSZip | null; (name: RegExp): JSZip.JSZipObject[] };- Returns an new JSZip instance with the given folder as root - Parameter name- Name of the folder New JSZip object with the given folder as root or null 
- Returns new JSZip instances with the matching folders as root - Parameter name- RegExp to match New array of JSZipFile objects which match the RegExp 
method forEach
forEach: (    callback: (relativePath: string, file: JSZip.JSZipObject) => void) => void;- Call a callback function for each entry at this folder level. - Parameter callback- function 
method generateAsync
generateAsync: <T extends keyof OutputByType>(    options?: JSZip.JSZipGeneratorOptions<T>,    onUpdate?: JSZip.OnUpdateCallback) => Promise<OutputByType[T]>;- Generates a new archive asynchronously - Parameter options- Optional options for the generator - Parameter onUpdate- The optional function called on each internal update with the metadata. The serialized archive 
method generateInternalStream
generateInternalStream: <T extends keyof OutputByType>(    options?: JSZip.JSZipGeneratorOptions<T>) => JSZip.JSZipStreamHelper<OutputByType[T]>;- Generates the complete zip file with the internal stream implementation - Parameter options- Optional options for the generator a StreamHelper 
method generateNodeStream
generateNodeStream: (    options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>,    onUpdate?: JSZip.OnUpdateCallback) => NodeJS.ReadableStream;- Generates a new archive asynchronously - Parameter options- Optional options for the generator - Parameter onUpdate- The optional function called on each internal update with the metadata. A Node.js - ReadableStream
method loadAsync
loadAsync: (    data: InputFileFormat,    options?: JSZip.JSZipLoadOptions) => Promise<JSZip>;- Deserialize zip file asynchronously - Parameter data- Serialized zip file - Parameter options- Options for deserializing Returns promise 
method remove
remove: (path: string) => JSZip;- Removes the file or folder from the archive - Parameter path- Relative path of file or folder Returns the JSZip instance 
construct signature
new (): this;- Create JSZip instance 
call signature
(): JSZip;interface JSZipFileOptions
interface JSZipFileOptions {}property base64
base64?: boolean;- Set to - trueif the data is- base64encoded. For example image data from a- <canvas>element. Plain text and HTML do not need this option.
property binary
binary?: boolean;- Set to - trueif the data should be treated as raw content,- falseif this is a text. If- base64is used, this defaults to- true, if the data is not a- string, this will be set to- true.
property comment
comment?: string;property compression
compression?: Compression;- Sets per file compression. The - compressionOptionsparameter depends on the compression type.
property compressionOptions
compressionOptions?: null | CompressionOptions;- Sets per file compression level for - DEFLATEcompression.
property createFolders
createFolders?: boolean;- Set to - trueif folders in the file path should be automatically created, otherwise there will only be virtual folders that represent the path to the file.
property date
date?: Date;- The last modification date, defaults to the current date. 
property dir
dir?: boolean;- Set to - trueif this is a directory and content should be ignored.
property dosPermissions
dosPermissions?: number | null;- 6 bits number. The DOS permissions of the file, if any. 
property optimizedBinaryString
optimizedBinaryString?: boolean;- Set to - trueif (and only if) the input is a "binary string" and has already been prepared with a- 0xFFmask.
property unixPermissions
unixPermissions?: number | string | null;- 16 bits number. The UNIX permissions of the file, if any. Also accepts a - stringrepresenting the octal value:- "644",- "755", etc.
interface JSZipGeneratorOptions
interface JSZipGeneratorOptions<T extends OutputType = OutputType> {}property comment
comment?: string;property compression
compression?: Compression;- Sets compression option for all entries that have not specified their own - compressionoption
property compressionOptions
compressionOptions?: null | CompressionOptions;- Sets compression level for - DEFLATEcompression.
property mimeType
mimeType?: string;- mime-type for the generated file. Useful when you need to generate a file with a different extension, ie: “.ods”. 'application/zip' 
property platform
platform?: 'DOS' | 'UNIX';- DOS (default) or UNIX 
property streamFiles
streamFiles?: boolean;- Stream the files and create file descriptors 
property type
type?: T;method encodeFileName
encodeFileName: (filename: string) => string;interface JSZipLoadOptions
interface JSZipLoadOptions {}property base64
base64?: boolean;property checkCRC32
checkCRC32?: boolean;property createFolders
createFolders?: boolean;property decodeFileName
decodeFileName?: (bytes: string[] | Uint8Array | Buffer) => string;property optimizedBinaryString
optimizedBinaryString?: boolean;interface JSZipMetadata
interface JSZipMetadata {}property currentFile
currentFile: string | null;property percent
percent: number;interface JSZipObject
interface JSZipObject {}property comment
comment: string;property date
date: Date;property dir
dir: boolean;property dosPermissions
dosPermissions: number | null;- The UNIX permissions of the file, if any. 
property name
name: string;property options
options: JSZipObjectOptions;property unixPermissions
unixPermissions: number | string | null;- The UNIX permissions of the file, if any. 
property unsafeOriginalName
unsafeOriginalName?: string;- Present for files loadded with - loadAsync. May contain ".." path components that could result in a zip-slip attack. See https://snyk.io/research/zip-slip-vulnerability
method async
async: <T extends keyof OutputByType>(    type: T,    onUpdate?: OnUpdateCallback) => Promise<OutputByType[T]>;- Prepare the content in the asked type. - Parameter type- the type of the result. - Parameter onUpdate- a function to call on each internal update. Promise the promise of the result. 
method nodeStream
nodeStream: (    type?: 'nodebuffer',    onUpdate?: OnUpdateCallback) => NodeJS.ReadableStream;interface JSZipObjectOptions
interface JSZipObjectOptions {}property compression
compression: Compression;interface JSZipStreamHelper
interface JSZipStreamHelper<T> {}method accumulate
accumulate: (updateCallback?: (metadata: JSZipMetadata) => void) => Promise<T>;- Read the whole stream and call a callback with the complete content - Parameter updateCallback- The function called every time the stream updates A Promise of the full content 
method on
on: {    (event: 'data', callback: DataEventCallback<T>): this;    (event: 'end', callback: EndEventCallback): this;    (event: 'error', callback: ErrorEventCallback): this;};- Register a listener on an event 
method pause
pause: () => this;- Pause the stream if the stream is running. Once paused, the stream stops sending data events - The current StreamHelper object, for chaining 
method resume
resume: () => this;- Resume the stream if the stream is paused. Once resumed, the stream starts sending data events again - The current StreamHelper object, for chaining 
Type Aliases
type DataEventCallback
type DataEventCallback<T> = (dataChunk: T, metadata: JSZipMetadata) => void;type EndEventCallback
type EndEventCallback = () => void;type ErrorEventCallback
type ErrorEventCallback = (error: Error) => void;type InputType
type InputType = keyof InputByType;type OnUpdateCallback
type OnUpdateCallback = (metadata: JSZipMetadata) => void;type OutputType
type OutputType = keyof OutputByType;Package Files (1)
Dependencies (4)
Dev Dependencies (14)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jszip.
- Markdown[](https://www.jsdocs.io/package/jszip)
- HTML<a href="https://www.jsdocs.io/package/jszip"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
 Package analyzed in 5093 ms.
- Missing or incorrect documentation? Open an issue for this package.
