mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
node : readable stream pipe can be piped further closes #1030
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import assert = require("assert");
|
||||
import fs = require("fs");
|
||||
import events = require("events");
|
||||
import zlib = require("zlib");
|
||||
|
||||
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
|
||||
|
||||
@@ -24,11 +25,11 @@ fs.writeFile("thebible.txt",
|
||||
assert.ifError);
|
||||
|
||||
fs.writeFile("Harry Potter",
|
||||
"\"You be wizzing, Harry,\" jived Dumbledore.",
|
||||
{
|
||||
encoding: "ascii"
|
||||
},
|
||||
assert.ifError);
|
||||
"\"You be wizzing, Harry,\" jived Dumbledore.",
|
||||
{
|
||||
encoding: "ascii"
|
||||
},
|
||||
assert.ifError);
|
||||
|
||||
class Networker extends events.EventEmitter {
|
||||
constructor() {
|
||||
@@ -36,4 +37,16 @@ class Networker extends events.EventEmitter {
|
||||
|
||||
this.emit("mingling");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Stream tests : http://nodejs.org/api/stream.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
|
||||
function stream_readable_pipe_test() {
|
||||
var r = fs.createReadStream('file.txt');
|
||||
var z = zlib.createGzip();
|
||||
var w = fs.createWriteStream('file.txt.gz');
|
||||
r.pipe(z).pipe(w);
|
||||
}
|
||||
4
node/node.d.ts
vendored
4
node/node.d.ts
vendored
@@ -998,7 +998,7 @@ declare module "stream" {
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
destroy(): void;
|
||||
pipe(destination: WritableStream, options?: { end?: boolean; }): void;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
}
|
||||
|
||||
export interface ReadableOptions {
|
||||
@@ -1014,7 +1014,7 @@ declare module "stream" {
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
destroy(): void;
|
||||
pipe(destination: WritableStream, options?: { end?: boolean; }): void;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
_read(): void;
|
||||
push(chunk: any, encoding?: string): boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user