A boolean that is `true` by default, but turns `false` after an `'error'`
occurred or `end()` / `destroy()` was called.
-### writeStream.write(data)
+### writeStream.write(data, encoding='utf8')
Returns `true` if the data was flushed to the kernel, and `false` if it was
queued up for being written later. A `'drain'` will fire after all queued data
has been written.
-You can also specify `callback` to be notified when the data from this write
-has been flushed. The first param is `err`, the second is `bytesWritten`.
+The second optional parameter specifies the encoding of for the string.
### writeStream.end()
this.busy = true;
- var
- method = args.shift(),
- cb = args.pop();
+ var method = args.shift(),
+ cb = args.pop();
var self = this;
};
-FileWriteStream.prototype.write = function(data, cb) {
+FileWriteStream.prototype.write = function(data, encoding) {
if (!this.writeable) {
throw new Error('stream not writeable');
}
- this._queue.push([fs.write, data, undefined, this.encoding, cb]);
+ // TODO handle Buffer
+
+ this._queue.push([fs.write, data, undefined, encoding || 'utf8', null]);
this.flush();
return false;
drain: -2,
close: -1,
endCb: -1,
- write: -11,
};
file
for (var i = 0; i < 11; i++) {
(function(i) {
- assert.strictEqual(false, file.write(i, function(err, bytesWritten) {
- callbacks.write++;
- assert.equal(new String(i).length, bytesWritten);
- }));
+ assert.strictEqual(false, file.write(i));
})(i);
}