UNPKG

860 BTypeScriptView Raw
1/// <reference types="node" />
2
3import stream = require("stream");
4
5export function Extract(options: { path: string }): NodeJS.WritableStream;
6export function Parse(): NodeJS.WritableStream;
7
8/**
9 * Code example from https://www.npmjs.com/package/unzip with type unzip.Entry added
10 * ```
11 * fs.createReadStream('path/to/archive.zip')
12 * .pipe(unzip.Parse())
13 * .on('entry', function (entry: unzip.Entry) {
14 * var fileName = entry.path;
15 * var type = entry.type; // 'Directory' or 'File'
16 * var size = entry.size;
17 * if (fileName === "this IS the file I'm looking for") {
18 * entry.pipe(fs.createWriteStream('output/path'));
19 * } else {
20 * entry.autodrain();
21 * }
22 * });
23 * ```
24 */
25export interface Entry extends stream.PassThrough {
26 path: string;
27 type: "Directory" | "File";
28 size: number;
29 autodrain: () => void;
30}