forked from ZJONSSON/node-unzipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unzip.d.ts
121 lines (108 loc) · 3.03 KB
/
unzip.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/// <reference types="node" />
import { ClientRequest, RequestOptions } from 'http'
import { Duplex, PassThrough, Readable, Transform } from 'stream'
export interface PullStream extends Duplex {
stream(eof: number | string, includeEof: boolean): PassThrough
pull(eof: number | string, includeEof: boolean): Promise<Buffer>
}
export interface Entry extends PassThrough {
autodrain(): Transform & {
promise(): Promise<void>
}
buffer(): Promise<Buffer>
path: string
props: {
path: string
}
type: string
vars: {
signature?: number | undefined
versionsNeededToExtract: number
flags: number
compressionMethod: number
lastModifiedTime: number
crc32: number
compressedSize: number
fileNameLength: number
extraFieldLength: number
}
extra: {
signature: number
partsize: number
uncompressedSize: number
compressedSize: number
offset: number
disknum: number
}
}
export function unzip(
source: {
stream: Readable
size: () => Promise<number>
},
offset: number,
_password: string
): Entry
export namespace Open {
function buffer(data: Buffer): Promise<CentralDirectory>
function file(filename: string): Promise<CentralDirectory>
function url(
request: ClientRequest,
opt: string | RequestOptions
): Promise<CentralDirectory>
function s3(client: any, params: any): Promise<CentralDirectory>
function storage(storage: { provider: { client: { parent: any }, details: { bucket?: string } } }, key: string): Promise<CentralDirectory>
function gcs(client: any, params: any): Promise<CentralDirectory>
}
export function BufferStream(entry: Entry): Promise<Buffer>
export interface CentralDirectory {
signature: number
diskNumber: number
diskStart: number
numberOfRecordsOnDisk: number
numberOfRecords: number
sizeOfCentralDirectory: number
offsetToStartOfCentralDirectory: number
commentLength: number
files: File[]
extract: (opts: ParseOptions) => Promise<void>
}
export interface File {
signature: number
versionMadeBy: number
versionsNeededToExtract: number
flags: number
compressionMethod: number
lastModifiedTime: number
lastModifiedDate: number
crc32: number
compressedSize: number
uncompressedSize: number
fileNameLength: number
extraFieldLength: number
fileCommentLength: number
diskNumber: number
internalFileAttributes: number
externalFileAttributes: number
offsetToLocalFileHeader: number
pathBuffer: Buffer
path: string
isUnicode: number
extra: any
type: 'Directory' | 'File'
comment: string
stream: (password?: string) => Entry
buffer: (password?: string) => Promise<Buffer>
}
export interface ParseOptions {
verbose?: boolean | undefined
path?: string | undefined
concurrency?: number | undefined
forceStream?: boolean | undefined
}
export type ParseStream = PullStream & {
promise(): Promise<void>
}
export function Parse(opts?: ParseOptions): ParseStream
export function ParseOne(match?: RegExp, opts?: ParseOptions): Duplex
export function Extract(opts?: ParseOptions): ParseStream