mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
unzipper: autodrain promise (#29281)
* update autodrain type * add test
This commit is contained in:
committed by
Wesley Wigham
parent
6b987fa09f
commit
46f3f013b5
6
types/unzipper/index.d.ts
vendored
6
types/unzipper/index.d.ts
vendored
@@ -7,7 +7,7 @@
|
||||
// TypeScript Version: 2.2
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Readable, Stream, PassThrough, Duplex } from "stream";
|
||||
import { Readable, Stream, PassThrough, Duplex, Transform } from "stream";
|
||||
import { ClientRequest, RequestOptions } from "http";
|
||||
|
||||
export interface PullStream extends Duplex {
|
||||
@@ -16,7 +16,9 @@ export interface PullStream extends Duplex {
|
||||
}
|
||||
|
||||
export interface Entry extends PassThrough {
|
||||
autodrain(): Promise<void>;
|
||||
autodrain(): Transform & {
|
||||
promise(): Promise<void>;
|
||||
};
|
||||
buffer(): Promise<Buffer>;
|
||||
path: string;
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { Parse, Open, Entry, CentralDirectory } from "unzipper";
|
||||
import { createReadStream } from 'fs';
|
||||
import { get } from 'http';
|
||||
import { CentralDirectory, Entry, Open, Parse } from 'unzipper';
|
||||
|
||||
import { createReadStream } from "fs";
|
||||
|
||||
import { get } from "http";
|
||||
createReadStream("http://example.org/path/to/archive.zip")
|
||||
.pipe(Parse())
|
||||
.on("entry", (entry: Entry) => {
|
||||
entry.autodrain().promise().then(() => {
|
||||
console.log("Finished draining stream");
|
||||
});
|
||||
});
|
||||
|
||||
createReadStream("http://example.org/path/to/archive.zip")
|
||||
.pipe(Parse())
|
||||
|
||||
Reference in New Issue
Block a user