diff --git a/node/node-tests.ts b/node/node-tests.ts index 040b259f7..cf73c11bc 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -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); } \ No newline at end of file diff --git a/node/node.d.ts b/node/node.d.ts index 9500b0123..9ae2d75ae 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -998,7 +998,7 @@ declare module "stream" { pause(): void; resume(): void; destroy(): void; - pipe(destination: WritableStream, options?: { end?: boolean; }): void; + pipe(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(destination: T, options?: { end?: boolean; }): T; _read(): void; push(chunk: any, encoding?: string): boolean; }