string-stream
Advanced tools
Comparing version 0.0.3 to 0.0.4
21
index.js
@@ -57,2 +57,23 @@ var Stream = require('stream'), | ||
}; | ||
/** | ||
* The write end to a stream buffer. | ||
*/ | ||
function Writable() { | ||
Writable.super_.call(this); | ||
this._data = ''; | ||
} | ||
inherits(Writable, Stream); | ||
Writable.prototype.write = function (data) { | ||
this._data += data; | ||
}; | ||
Writable.prototype.end = function () { | ||
this.write.apply(this, arguments); | ||
this.emit('end'); | ||
}; | ||
Writable.prototype.toString = function () { | ||
return this._data; | ||
}; | ||
exports.Readable = Readable; | ||
exports.Writable = Writable; |
{ | ||
"name": "string-stream", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A stream that works on a string.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var Readable = require('..').Readable, | ||
Writable = require('..').Writable, | ||
Pipe = require('pipette').Pipe; | ||
@@ -22,1 +23,11 @@ require('should'); | ||
}); | ||
describe('Writable stream', function () { | ||
it('should write the given data', function (done) { | ||
var stream = new Writable(); | ||
stream.on('end', function () { | ||
stream.toString().should.equal('Test content'); | ||
done(); | ||
}); | ||
stream.end('Test content'); | ||
}); | ||
}); |
3704
96