123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- import { ReadStream, WriteStream } from 'fs'
- type sourceType = string | Buffer | ReadStream
- type destType = string | WriteStream
- interface streamEntryOpts {
- relativePath?: string
- ignoreBase?: boolean
- size?: number
- suppressSizeWarning?: boolean
- }
- interface streamHeader {
- type: 'file' | 'directory',
- name: string
- }
- interface streamHeaderWithMode {
- type: 'file' | 'directory',
- name: string
- mode: number
- }
- export namespace gzip {
- function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
- function uncompress(source: sourceType, dest: destType, opts?: any): Promise<void>
- function decompress(source: sourceType, dest: destType, opts?: any): Promise<void>
- export class FileStream extends ReadStream {
- constructor(opts?: {
- zlib?: object,
- source: sourceType
- });
- }
- export class UncompressStream extends WriteStream {
- constructor(opts?: {
- zlib?: object,
- source: sourceType
- });
- on(event: string, listener: (...args: any[]) => void): this
- on(event: 'error', listener: (err: Error) => void): this
- }
- }
- export namespace tar {
- function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
- function compressDir(source: sourceType, dest: destType, opts?: any): Promise<void>
- function uncompress(source: sourceType, dest: string, opts?: any): Promise<void>
- function decompress(source: sourceType, dest: string, opts?: any): Promise<void>
- export class Stream extends ReadStream {
- constructor();
- addEntry(entry: string, opts?: streamEntryOpts): void
- addEntry(entry: Buffer | ReadStream, opts: streamEntryOpts): void
- }
- export class FileStream extends ReadStream {
- constructor(opts?: {
- relativePath?: string,
- size?: number,
- suppressSizeWarning?: boolean,
- source?: sourceType
- });
- }
- export class UncompressStream extends WriteStream {
- constructor(opts?: {
- source: sourceType
- });
- on(event: string, listener: (...args: any[]) => void): this
- on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
- on(event: 'finish', listener: () => void): this
- on(event: 'error', listener: (err: Error) => void): this
- }
- }
- export namespace tgz {
- function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
- function compressDir(source: sourceType, dest: destType, opts?: any): Promise<void>
- function uncompress(source: sourceType, dest: string, opts?: any): Promise<void>
- function decompress(source: sourceType, dest: string, opts?: any): Promise<void>
- export class Stream extends ReadStream {
- constructor();
- addEntry(entry: string, opts?: streamEntryOpts): void
- addEntry(entry: Buffer | ReadStream, opts: streamEntryOpts): void
- }
- export class FileStream extends ReadStream {
- constructor(opts?: {
- relativePath?: string,
- size?: number,
- suppressSizeWarning?: boolean,
- zlib?: object,
- source?: sourceType
- });
- }
- export class UncompressStream extends WriteStream {
- constructor(opts?: {
- source?: sourceType,
- strip?: number
- });
- on(event: string, listener: (...args: any[]) => void): this
- on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
- on(event: 'finish', listener: () => void): this
- on(event: 'error', listener: (err: Error) => void): this
- }
- }
- export namespace zip {
- function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
- function compressDir(source: sourceType, dest: destType, opts?: any): Promise<void>
- function uncompress(source: sourceType, dest: string, opts?: any): Promise<void>
- function decompress(source: sourceType, dest: string, opts?: any): Promise<void>
- export class Stream extends ReadStream {
- constructor();
- addEntry(entry: string, opts?: streamEntryOpts): void
- addEntry(entry: Buffer | ReadStream, opts: streamEntryOpts): void
- }
- export class FileStream extends ReadStream {
- /**
- * If opts.source is a file path, opts.relativePath is optional, otherwise it's required.
- *
- * @param opts
- */
- constructor(opts?: {
- relativePath?: string,
- yazl?: object,
- source: string
- } | {
- relativePath: string,
- yazl?: object,
- source?: Buffer | ReadStream
- });
- }
- export class UncompressStream extends WriteStream {
- constructor(opts?: {
- source?: sourceType,
- strip?: number,
- zipFileNameEncoding?: string
- });
- on(event: string, listener: (...args: any[]) => void): this
- on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
- on(event: 'finish', listener: () => void): this
- on(event: 'error', listener: (err: Error) => void): this
- }
- }
|