forked from Touffy/client-zip
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
43 lines (33 loc) · 2.69 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
type BufferLike = ArrayBuffer | string | ArrayBufferView | Blob
type StreamLike = ReadableStream<Uint8Array> | AsyncIterable<BufferLike>
/** The file name, modification date and size will be read from the input;
* extra arguments can be given to override the input’s metadata. */
type InputWithMeta = File | Response | { input: File | Response, name?: any, lastModified?: any, size?: number | bigint }
/** Intrinsic size, but the file name must be provided and modification date can’t be guessed. */
type InputWithSizeMeta = { input: BufferLike, name: any, lastModified?: any, size?: number | bigint }
/** The file name must be provided ; modification date and content length can’t be guessed. */
type InputWithoutMeta = { input: StreamLike, name: any, lastModified?: any, size?: number | bigint }
/** The folder name must be provided ; modification date can’t be guessed. */
type InputFolder = { name: any, lastModified?: any, input?: never, size?: never }
/** Both filename and size must be provided ; input is not helpful here. */
type JustMeta = { input?: StreamLike | undefined, name: any, lastModified?: any, size: number | bigint }
type ForAwaitable<T> = AsyncIterable<T> | Iterable<T>
type Options = {
/** If provided, the returned Response will have its `Content-Length` header set to this value.
* It can be computed accurately with the `predictLength` function. */
length?: number | bigint
/** If provided, the returned Response will have its `Content-Length` header set to the result of
* calling `predictLength` on that metadata. Overrides the `length` option. */
metadata?: Iterable<InputWithMeta | InputWithSizeMeta | JustMeta>
/** The ZIP *language encoding flag* will always be set when a filename was given as a string,
* but when it is given as an ArrayView or ArrayBuffer, it depends on this option :
* - `true`: always on (ArrayBuffers will *always* be flagged as UTF-8) — recommended,
* - `false`: always off (ArrayBuffers will *never* be flagged as UTF-8),
* - `undefined`: each ArrayBuffer will be tested and flagged if it is valid UTF-8. */
buffersAreUTF8?: boolean
}
/** Given an iterable of file metadata (or equivalent),
* @returns the exact byte length of the Zip file that would be generated by `downloadZip`. */
export declare function predictLength(files: Iterable<InputWithMeta | InputWithSizeMeta | JustMeta | InputFolder>): bigint
export declare function downloadZip(files: ForAwaitable<InputWithMeta | InputWithSizeMeta | InputWithoutMeta | InputFolder>, options?: Options): Response
export declare function makeZip(files: ForAwaitable<InputWithMeta | InputWithSizeMeta | InputWithoutMeta | InputFolder>, options?: Options): ReadableStream<Uint8Array>