mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 11:51:10 +08:00
* archiver clean up and updated version * added tslint.json * added back in create because it still works. Updated examples * fixed listing issues * fixed more linting issues * added glob options and EntryData * added more to tests * fixed tests by returning this, instead of void * removed whitespace * Add node types import * Keep original author
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
// Type definitions for archiver 1.3
|
|
// Project: https://github.com/archiverjs/node-archiver
|
|
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>, Dolan Miu <https://github.com/dolanmiu>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
/* =================== USAGE ===================
|
|
|
|
import Archiver = require('archiver);
|
|
var archiver = Archiver.create('zip');
|
|
archiver.pipe(fs.createWriteStream('xxx'));
|
|
archiver.append(fs.createReadStream('xxx'));
|
|
archiver.finalize();
|
|
|
|
=============================================== */
|
|
|
|
/// <reference types="node" />
|
|
|
|
import * as fs from 'fs';
|
|
import * as stream from 'stream';
|
|
import * as express from 'express';
|
|
import * as glob from 'glob';
|
|
|
|
declare function archiver(format: archiver.Format, options?: archiver.ArchiverOptions): archiver.Archiver;
|
|
|
|
declare namespace archiver {
|
|
type Format = 'zip' | 'tar';
|
|
|
|
function create(format: string, options?: ArchiverOptions): Archiver;
|
|
function registerFormat(format: string, module: Function): void;
|
|
|
|
interface EntryData {
|
|
name?: string;
|
|
prefix?: string;
|
|
stats?: string;
|
|
}
|
|
|
|
interface Archiver extends stream.Transform {
|
|
abort(): this;
|
|
append(source: stream.Readable | Buffer | string, name?: EntryData): this;
|
|
|
|
bulk(mappings: any): this;
|
|
|
|
directory(dirpath: string, options: EntryData | string, data?: EntryData): this;
|
|
|
|
file(filename: string, data: EntryData): this;
|
|
glob(pattern: string, options?: glob.IOptions, data?: EntryData): this;
|
|
finalize(): this;
|
|
|
|
pipe(stream: fs.WriteStream | express.Response): void;
|
|
|
|
setFormat(format: string): this;
|
|
setModule(module: Function): this;
|
|
|
|
pointer(): number;
|
|
use(plugin: Function): this;
|
|
}
|
|
|
|
interface ArchiverOptions {
|
|
store?: boolean;
|
|
gzip?: boolean;
|
|
gzipOptions?: {
|
|
level: number,
|
|
};
|
|
}
|
|
}
|
|
|
|
export = archiver;
|