1 | var WritableStream = require("./WritableStream.js");
|
2 |
|
3 | var Stream = function(options){
|
4 | WritableStream.call(this, new cbs(this), options);
|
5 | };
|
6 |
|
7 | require("util").inherits(Stream, WritableStream);
|
8 |
|
9 | Stream.prototype.readable = true;
|
10 |
|
11 | var cbs = function(scope){
|
12 | this.scope = scope;
|
13 | };
|
14 |
|
15 | var EVENTS = require("../").EVENTS;
|
16 |
|
17 | Object.keys(EVENTS).forEach(function(name){
|
18 | if(EVENTS[name] === 0){
|
19 | cbs.prototype["on" + name] = function(){
|
20 | this.scope.emit(name);
|
21 | };
|
22 | } else if(EVENTS[name] === 1){
|
23 | cbs.prototype["on" + name] = function(a){
|
24 | this.scope.emit(name, a);
|
25 | };
|
26 | } else if(EVENTS[name] === 2){
|
27 | cbs.prototype["on" + name] = function(a, b){
|
28 | this.scope.emit(name, a, b);
|
29 | };
|
30 | } else {
|
31 | throw Error("wrong number of arguments!");
|
32 | }
|
33 | });
|
34 |
|
35 | module.exports = Stream; |
\ | No newline at end of file |