Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit 9415d5d

Browse files
committed
Major reworking of streams
Update the annotations to match their definitions in node 0.10. Also, stream (the namespace) is not a class, use stream.Stream instead as appropriate. This commit doesn't fix the multiple inheritance/mixin issue with Duplex needing to extend from both Readable and Writable. This may require defining some interfaces which can be implemented. This commit also doesn't touch ReadableStream and WritableStream. I'm not sure of the purpose of these classes and since they are heavily used in other namespaces, I'll leave them alone for now. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
1 parent 338e07e commit 9415d5d

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

repl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
var repl = {};
3535

3636
/**
37-
* @param {{prompt: ?string, input: ?stream, output: ?stream, terminal: ?boolean, eval: ?function(string), useColors: ?boolean, useGlobal: ?boolean, ignoreUndefined: ?boolean, writer: ?function(string)}} options
37+
* @param {{prompt: ?string, input: ?stream.Readable, output: ?stream.Writable, terminal: ?boolean, eval: ?function(string), useColors: ?boolean, useGlobal: ?boolean, ignoreUndefined: ?boolean, writer: ?function(string)}} options
3838
* @return {repl.REPLServer}
3939
*/
4040
repl.start = function(options) {};

stream.js

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,21 @@
2828
END_NODE_INCLUDE
2929
*/
3030

31+
var stream = {};
32+
3133
/**
3234
* @constructor
35+
* @param {Object=} options
3336
* @extends events.EventEmitter
3437
*/
35-
var stream = function() {};
38+
stream.Stream = function(options) {};
3639

3740
/**
38-
* @type {stream}
41+
* @param {stream.Writable} dest
42+
* @param {{end: boolean}=} pipeOpts
43+
* @return {stream.Writable}
3944
*/
40-
stream.Stream = function() {};
45+
stream.Stream.prototype.pipe = function(dest, pipeOpts) {};
4146

4247
/**
4348
* @constructor
@@ -99,23 +104,25 @@ stream.WritableStream.prototype.destroySoon = function() {};
99104
/**
100105
* @constructor
101106
* @param {Object=} options
102-
* @extends stream
107+
* @extends stream.Stream
103108
*/
104109
stream.Readable = function(options) {};
105110

106111
/**
107112
* @type {boolean}
113+
* @deprecated
108114
*/
109115
stream.Readable.prototype.readable;
110116

111117
/**
112-
* @param {string|buffer.Buffer} chunk
118+
* @protected
119+
* @param {string|buffer.Buffer|null} chunk
113120
* @return {boolean}
114121
*/
115122
stream.Readable.prototype.push = function(chunk) {};
116123

117124
/**
118-
* @param {string|buffer.Buffer} chunk
125+
* @param {string|buffer.Buffer|null} chunk
119126
* @return {boolean}
120127
*/
121128
stream.Readable.prototype.unshift = function(chunk) {};
@@ -126,26 +133,19 @@ stream.Readable.prototype.unshift = function(chunk) {};
126133
stream.Readable.prototype.setEncoding = function(enc) {};
127134

128135
/**
129-
* @param {number} n
130-
* @return {buffer.Buffer}
136+
* @param {number=} n
137+
* @return {buffer.Buffer|string|null}
131138
*/
132139
stream.Readable.prototype.read = function(n) {};
133140

134141
/**
142+
* @protected
135143
* @param {number} n
136-
* @return {?buffer.Buffer}
137144
*/
138145
stream.Readable.prototype._read = function(n) {};
139146

140147
/**
141-
* @param {stream.Writable} dest
142-
* @param {{end: boolean}=} pipeOpts
143-
* @return {stream.Writable}
144-
*/
145-
stream.Readable.prototype.pipe = function(dest, pipeOpts) {};
146-
147-
/**
148-
* @param {stream.Writable} dest
148+
* @param {stream.Writable=} dest
149149
* @return {stream.Readable}
150150
*/
151151
stream.Readable.prototype.unpipe = function(dest) {};
@@ -159,54 +159,52 @@ stream.Readable.prototype.resume = function() {};
159159
stream.Readable.prototype.pause = function() {};
160160

161161
/**
162-
* @param {stream} stream
162+
* @param {stream.Stream} stream
163+
* @return {stream.Readable}
163164
*/
164165
stream.Readable.prototype.wrap = function(stream) {};
165166

166167
/**
167168
* @constructor
168169
* @param {Object=} options
169-
* @extends stream
170+
* @extends stream.Stream
170171
*/
171172
stream.Writable = function(options) {};
172173

173174
/**
175+
* @deprecated
174176
* @type {boolean}
175177
*/
176178
stream.Writable.prototype.writable;
177179

178-
/**
179-
*/
180-
stream.Writable.prototype.pipe = function() {};
181-
182180
/**
183181
* @param {string|buffer.Buffer} chunk
184-
* @param {(string|function(...))=} encoding
185-
* @param {function(...)=} cb
182+
* @param {string=} encoding
183+
* @param {function(*=)=} cb
186184
* @return {boolean}
187185
*/
188186
stream.Writable.prototype.write = function(chunk, encoding, cb) {};
189187

190188
/**
189+
* @protected
191190
* @param {string|buffer.Buffer} chunk
192-
* @param {(string|function(...))=} encoding
193-
* @param {function(...)=} cb
191+
* @param {string} encoding
192+
* @param {function(*=)} cb
194193
*/
195194
stream.Writable.prototype._write = function(chunk, encoding, cb) {};
196195

197196
/**
198-
* @param {string|buffer.Buffer} chunk
199-
* @param {(string|function(...))=} encoding
200-
* @param {function(...)=} cb
201-
* @return {boolean}
197+
* @param {string|buffer.Buffer=} chunk
198+
* @param {string=} encoding
199+
* @param {function(*=)=} cb
202200
*/
203201
stream.Writable.prototype.end = function(chunk, encoding, cb) {};
204202

205203
/**
206204
* @constructor
207205
* @param {Object=} options
208206
* @extends stream.Readable
209-
* @implements stream.Writable
207+
* Xextends stream.Writable
210208
*/
211209
stream.Duplex = function(options) {};
212210

@@ -224,11 +222,18 @@ stream.Duplex.prototype.allowHalfOpen;
224222
stream.Transform = function(options) {};
225223

226224
/**
225+
* @protected
227226
* @param {string|buffer.Buffer} chunk
228-
* @param {*} output
227+
* @param {string} encoding
228+
* @param {function(*=)} cb
229+
*/
230+
stream.Transform._transform = function(chunk, encoding, cb) {};
231+
232+
/**
233+
* @protected
229234
* @param {function(*=)} cb
230235
*/
231-
stream.Transform._transform = function(chunk, output, cb) {};
236+
stream.Transform._flush = function(cb) {};
232237

233238
/**
234239
* @param {Object=} options

tls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ tls.Server.prototype.connections;
115115

116116
/**
117117
* @constructor
118-
* @extends stream
118+
* @extends stream.Duplex
119119
*/
120120
tls.CleartextStream = function() {};
121121

zlib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ zlib.Options;
4242

4343
/**
4444
* @constructor
45-
* @extends stream.WriteStream
45+
* @extends stream.Transform
4646
*/
4747
zlib.Zlib = function() {};
4848

0 commit comments

Comments
 (0)