Permalink
Browse files

v0.0.5

  • Loading branch information...
1 parent d0abaa8 commit 0e6fc30b90a599ab9d18000091fab72c48e4dd60 Gabriel Llamas committed Apr 15, 2012
Showing with 7 additions and 15 deletions.
  1. +1 −1 README.md
  2. +1 −1 build/buffered-reader.js
  3. +1 −1 build/package.json
  4. +3 −11 src/buffered-reader.js
  5. +1 −1 src/package.json
View
2 README.md
@@ -7,7 +7,7 @@ Node BufferedReader
[Availability](#availability) | [Compatibility](#compatibility) | [Documentation](#documentation)
-Version: 0.0.4
+Version: 0.0.5
<a name="availability"></a>
#### Availability [](#start) ####
View
2 build/buffered-reader.js
@@ -1 +1 @@
-"use strict";var EVENTS=require("events"),FS=require("fs"),PATH=require("path"),BUFFER_SIZE=16384,SLASH=PATH.normalize("/"),getFileName=function(a){var b=process.mainModule.filename,c=b.substring(0,b.lastIndexOf(SLASH)),d=PATH.relative(process.cwd(),c);return PATH.join(d,a)},BufferedReader=function(a,b,c){EVENTS.EventEmitter.call(this);var d=arguments.length;d===1?(b=BUFFER_SIZE,c=null):d===2&&typeof b=="string"&&(c=b,b=BUFFER_SIZE),this._settings={encoding:c,bufferSize:b},this._fileName=getFileName(a)};BufferedReader.prototype=Object.create(EVENTS.EventEmitter.prototype),BufferedReader.prototype.constructor=BufferedReader,BufferedReader.prototype.read=function(){var a=FS.createReadStream(this._fileName,this._settings),b=this,c,d,b=this,e=this.listeners("character").length!==0||this.listeners("line").length!==0||this.listeners("byte").length!==0;a.on("data",function(f){d=f;var g=0,h,i,j=f.length;if(e){for(var k=0;k<j;k++){i=f[k];if(!a.encoding){b.emit("byte",i);continue}b.emit("character",i==="\r"?"\n":i);if(i==="\n"||i==="\r")h=f.slice(g,k),g=k+1,c&&(h=c.concat(h),c=null),k+1!==j&&i==="\r"&&f[k+1]==="\n"&&k++,b.emit("line",h)}if(a.encoding&&g!==j){var l=g===0?f:f.slice(g);c=c?c.concat(l):l}}b.emit("buffer",f)}),a.on("end",function(){e&&c&&b.emit("line",c),b.emit("end")}),a.on("error",function(a){b.emit("error",a)})},module.exports.BufferedReader=BufferedReader;
+"use strict";var EVENTS=require("events"),FS=require("fs"),PATH=require("path"),BUFFER_SIZE=16384,SLASH=PATH.normalize("/"),BufferedReader=function(a,b,c){EVENTS.EventEmitter.call(this);var d=arguments.length;d===1?(b=BUFFER_SIZE,c=null):d===2&&typeof b=="string"&&(c=b,b=BUFFER_SIZE),this._settings={encoding:c,bufferSize:b},this._fileName=a};BufferedReader.prototype=Object.create(EVENTS.EventEmitter.prototype),BufferedReader.prototype.constructor=BufferedReader,BufferedReader.prototype.read=function(){var a=FS.createReadStream(this._fileName,this._settings),b,c,d=this,e=this.listeners("character").length!==0||this.listeners("line").length!==0||this.listeners("byte").length!==0;a.on("data",function(f){c=f;var g=0,h,i,j=f.length;if(e){for(var k=0;k<j;k++){i=f[k];if(!a.encoding){d.emit("byte",i);continue}d.emit("character",i==="\r"?"\n":i);if(i==="\n"||i==="\r")h=f.slice(g,k),g=k+1,b&&(h=b.concat(h),b=null),k+1!==j&&i==="\r"&&f[k+1]==="\n"&&k++,d.emit("line",h)}if(a.encoding&&g!==j){var l=g===0?f:f.slice(g);b=b?b.concat(l):l}}d.emit("buffer",f)}),a.on("end",function(){e&&b&&d.emit("line",b),d.emit("end")}),a.on("error",function(a){d.emit("error",a)})},module.exports.BufferedReader=BufferedReader;
View
2 build/package.json
@@ -3,7 +3,7 @@
"author": {
"name": "Gabriel Llamas"
},
- "version": "0.0.4",
+ "version": "0.0.5",
"description": "Fully configurable buffered reader.",
"repository": {
"type": "git",
View
14 src/buffered-reader.js
@@ -4,8 +4,8 @@
*
* @author Gabriel Llamas
* @created 10/04/2012
- * @modified 11/04/2012
- * @version 0.0.4
+ * @modified 16/04/2012
+ * @version 0.0.5
*/
"use strict";
@@ -16,13 +16,6 @@ var PATH = require ("path");
var BUFFER_SIZE = 16384;
var SLASH = PATH.normalize ("/");
-var getFileName = function (fileName){
- var main = process.mainModule.filename;
- var cwd = main.substring (0, main.lastIndexOf (SLASH));
- var relative = PATH.relative (process.cwd (), cwd);
- return PATH.join (relative, fileName);
-};
-
var BufferedReader = function (fileName, bufferSize, encoding){
EVENTS.EventEmitter.call (this);
@@ -40,7 +33,7 @@ var BufferedReader = function (fileName, bufferSize, encoding){
bufferSize: bufferSize
};
- this._fileName = getFileName (fileName);
+ this._fileName = fileName;
};
BufferedReader.prototype = Object.create (EVENTS.EventEmitter.prototype);
@@ -49,7 +42,6 @@ BufferedReader.prototype.constructor = BufferedReader;
BufferedReader.prototype.read = function (){
var stream = FS.createReadStream (this._fileName, this._settings);
- var me = this;
var lastChunk;
var buffer;
var me = this;
View
2 src/package.json
@@ -3,7 +3,7 @@
"author": {
"name": "Gabriel Llamas"
},
- "version": "0.0.4",
+ "version": "0.0.5",
"description": "Fully configurable buffered reader.",
"repository": {
"type": "git",

0 comments on commit 0e6fc30

Please sign in to comment.