borisyankov/DefinitelyTyped — pull request #993 by antiveeranna (2013-09-04 10:22:10+00:00)
Title: describe stream.Readable class

Describe node Stream.Readable class, this allows implementing of Readable streams as described in http://nodejs.org/api/stream.html#stream_class_stream_readable_1

Specifically the Counting Stream example can now be implemented in TypeScript like this:

```javascript
import stream = require('stream');
export class Counter extends stream.Readable {

private _max = 100;
private _index = 1;

constructor(opts?: stream.ReadableOptions) {
super(opts);
}

_read() {
var i = this._index++;
if (i > this._max) {
this.push(null);
} else {
var str = '' + i;
var buf = new Buffer(str, 'ascii');
this.push(buf);
}
}
}

var c = new Counter();
c.on('data', function (item) {
console.log(item);
});
```