Permalink
Browse files

v0.2.3

  • Loading branch information...
1 parent aa00de6 commit d9382cfec4ff4ff347d0ba07d67278eb1040f2fd Gabriel Llamas committed Dec 11, 2012
Showing with 18 additions and 15 deletions.
  1. +4 −1 CHANGES
  2. +1 −1 README.md
  3. +11 −11 buffered-writer.js
  4. +2 −2 package.json
View
@@ -1,4 +1,7 @@
-v0.2.2 (10 Dec 2012)
+v0.2.3 (11 Dec 2012)
+ Replaces "errno-codes" dependency by "error-provider".
+
+v0.2.2 (11 Dec 2012)
Added "mode" and "start" to the "open()" parameters.
Added "writeln()".
Added "flush()".
View
@@ -5,7 +5,7 @@ _Node.js project_
#### Writes buffered data ####
-Version: 0.2.2
+Version: 0.2.3
Node.js streams are not buffered, that is, when you write data to them you're doing multiple I/O calls. This module buffers the data that has to be written to disk and eases the buffer manipulation when you need to write data from different nature (strings, numbers, arrays or buffers).
View
@@ -2,16 +2,16 @@
var EVENTS = require ("events");
var FS = require ("fs");
-var errno = require ("errno-codes");
+var ep = require ("error-provider");
-errno.create (errno.getNextAvailableErrno (), "INVALID_BUFFER_SIZE",
+ep.create (ep.next (), "INVALID_BUFFER_SIZE",
"The buffer size must be greater than 0.");
-errno.create (errno.getNextAvailableErrno (), "STREAM_CLOSED",
+ep.create (ep.next (), "STREAM_CLOSED",
"The stream is already closed, cannot write nor close it again.");
-errno.create (errno.getNextAvailableErrno (), "INVALID_OFFSET_LENGTH",
+ep.create (ep.next (), "INVALID_OFFSET_LENGTH",
"The offset or length parameters are not valid (offset={offset}, " +
"length={length}, length-offset<0).");
-errno.create (errno.getNextAvailableErrno (), "INVALID_DATA",
+ep.create (ep.next (), "INVALID_DATA",
"The data can only be a Number, String, Array or Buffer");
var BUFFER_SIZE = 16384;
@@ -27,7 +27,7 @@ bw.open = function (file, args){
if (args.bufferSize === 0) args.bufferSize = -1;
args.bufferSize = args.bufferSize || BUFFER_SIZE;
- if (args.bufferSize < 1) throw errno.get ("INVALID_BUFFER_SIZE");
+ if (args.bufferSize < 1) throw ep.get ("INVALID_BUFFER_SIZE");
return new Writer (file, args);
};
@@ -103,7 +103,7 @@ Writer.prototype._write = function (data, offset, length){
Writer.prototype.close = function (cb){
if (this._closed){
- return this._error (errno.get ("STREAM_CLOSED"));
+ return this._error (ep.get ("STREAM_CLOSED"));
}
if (this._offset){
@@ -129,7 +129,7 @@ Writer.prototype.flush = function (cb){
Writer.prototype.line = function (){
if (this._closed){
- return this._error (errno.get ("STREAM_CLOSED"));
+ return this._error (ep.get ("STREAM_CLOSED"));
}
this._write (EOL, 0, EOL.length);
return this;
@@ -146,7 +146,7 @@ var toHexArray = function (n){
Writer.prototype.write = function (buffer, offset, length){
if (this._closed){
- return this._error (errno.get ("STREAM_CLOSED"));
+ return this._error (ep.get ("STREAM_CLOSED"));
}
offset = offset || 0;
@@ -171,15 +171,15 @@ Writer.prototype.write = function (buffer, offset, length){
}else{
var me = this;
this.close (function (){
- me._error (errno.get ("INVALID_DATA"));
+ me._error (ep.get ("INVALID_DATA"));
});
return;
}
if (stringError || length < 0){
var me = this;
this.close (function (){
- me._error (errno.get ("INVALID_OFFSET_LENGTH", {
+ me._error (ep.get ("INVALID_OFFSET_LENGTH", {
offset: offset,
length: length
}));
View
@@ -1,6 +1,6 @@
{
"name": "buffered-writer",
- "version": "0.2.2",
+ "version": "0.2.3",
"description": "Writes buffered data to files",
"keywords": ["buffer", "write", "stream", "file", "binary", "data"],
"author": {
@@ -15,7 +15,7 @@
"node": "*"
},
"dependencies": {
- "errno-codes": "*"
+ "error-provider": "*"
},
"licenses": [{
"type": "MIT",

0 comments on commit d9382cf

Please sign in to comment.