mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
BufferList.concat
This commit is contained in:
parent
871f529fea
commit
bf03dbf3f8
@ -34,7 +34,8 @@ stringToHex = function(string) {
|
||||
hexToString = function(hexArray) {
|
||||
return new Buffer(hexArray).toString('utf8');
|
||||
}
|
||||
var BufferList = function() {
|
||||
|
||||
BufferList = function() {
|
||||
this.buffers = [];
|
||||
};
|
||||
|
||||
@ -84,3 +85,11 @@ BufferList.prototype.join = function(appendLength, char) {
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
BufferList.concat = function() {
|
||||
var total = new BufferList();
|
||||
for(var i = 0; i < arguments.length; i++) {
|
||||
total.add(arguments[i]);
|
||||
}
|
||||
return total.join();
|
||||
};
|
||||
|
||||
@ -63,3 +63,10 @@ test('does complicated buffer', function() {
|
||||
.join(true,'!');
|
||||
assert.equalBuffers(buf, [33, 0, 0, 0, 0x0c, 0, 0, 0, 1, 0, 2, 33, 0]);
|
||||
});
|
||||
|
||||
test('concats', function() {
|
||||
var buf1 = new BufferList().addInt32(8).join(false,'!');
|
||||
var buf2 = new BufferList().addInt16(1).join();
|
||||
var result = BufferList.concat(buf1, buf2);
|
||||
assert.equalBuffers(result, [33, 0, 0, 0, 8, 0, 1]);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user