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 | switch(EVENTS[name]){
|
19 | case 0:{
|
20 | cbs.prototype["on" + name] = function(){
|
21 | this.scope.emit(name);
|
22 | };
|
23 | break;
|
24 | }
|
25 | case 1:{
|
26 | cbs.prototype["on" + name] = function(a){
|
27 | this.scope.emit(name, a);
|
28 | };
|
29 | break;
|
30 | }
|
31 | case 2:{
|
32 | cbs.prototype["on" + name] = function(a, b){
|
33 | this.scope.emit(name, a, b);
|
34 | };
|
35 | break;
|
36 | }
|
37 | default: throw Error("wrong number of arguments!");
|
38 | }
|
39 | });
|
40 |
|
41 | module.exports = Stream; |
\ | No newline at end of file |