added 'addChar' method

This commit is contained in:
brianc 2010-10-10 17:40:11 -05:00
parent 94811981d6
commit 61ff6055b7

View File

@ -30,6 +30,10 @@ BufferList.prototype.addCString = function(val) {
return this.add(Buffer(val + '\0','utf8'));
};
BufferList.prototype.addChar = function(char, first) {
return this.add(Buffer(char,'utf8'), true);
};
BufferList.prototype.join = function(appendLength, char) {
var length = this.getByteLength();
if(appendLength) {
@ -37,7 +41,7 @@ BufferList.prototype.join = function(appendLength, char) {
return this.join(false, char);
}
if(char) {
this.buffers.unshift(Buffer(char,'utf8'));
this.addChar(char, true);
length++;
}
var result = Buffer(length);