Skip to content

Commit

Permalink
Merge pull request #25 from acsaga/master
Browse files Browse the repository at this point in the history
refactor con.r function
  • Loading branch information
amark committed Feb 28, 2012
2 parents 5e05c0a + c71355e commit 402bc03
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mongous.js
Expand Up @@ -41,7 +41,7 @@ con = function() {
con.r = function(res) { // function to handle all responses from Mongo
if(con.c.br > 0 && con.c.som > 0){
var rb = con.c.som - con.c.br;
if(rb > res.length){
if(rb > res.length) {
var b = new Buffer(con.c.b.length + res.length);
con.c.b.copy(b, 0,0, con.c.b.length);
res.copy(b, con.c.b.length,0, res.length);
Expand Down Expand Up @@ -77,8 +77,8 @@ con = function() {
con.c.b = b;
con.c.br = res.length;
con.c.som = som;
} else if(som == res.length){
var r = new mr(res);
} else if(som <= res.length){
var r = new mr(res.slice(0,som));
if(con.s){
con.c.emit(r.responseTo.toString(),r);
} else {
Expand All @@ -90,10 +90,9 @@ con = function() {
con.s = false;
}
}
} else if(som < res.length){
var r = new mr(res.slice(0,som));
con.c.emit(r.responseTo.toString(),r);
con.r(res.slice(som,res.length));
if(som < res.length) {
con.r(res.slice(som,res.length));
}
}
} else {
con.c.sb = res;
Expand Down Expand Up @@ -217,7 +216,7 @@ mongous = function() {
}
} else
if (this.col.search(/^[a-z|\_]/i) < 0) {
console.log("Error: '" + s + "' - Collection must start with a letter or an$ underscore.");
console.log("Error: '" + s + "' - Collection must start with a letter or an underscore.");
e = true;
}
}
Expand Down Expand Up @@ -383,7 +382,7 @@ mongous = function() {
return this.emit('log', " - Error: " + error.toString().replace(/error:/i, ''));
};
mongous.prototype.id = function() {
return Math.round(Math.random() * 80000);
return Math.round(Math.random() * 80000);
};
return mongous;
}();
Expand Down

0 comments on commit 402bc03

Please sign in to comment.