mirror of
https://github.com/danbulant/node-x11
synced 2026-05-19 04:18:35 +00:00
Fixed the unpack stream so arrays can work
This commit is contained in:
parent
2d7ffc2bcd
commit
d1868d5ee8
1 changed files with 3 additions and 1 deletions
|
|
@ -269,12 +269,14 @@ UnpackStream.prototype.pack = function(format, args)
|
|||
buf[offset++] = (n >> 16) & 0xff;
|
||||
buf[offset++] = (n >> 24) & 0xff;
|
||||
break;
|
||||
case 'a': // string or buffer
|
||||
case 'a': // string, buffer, or array
|
||||
var str = args[arg++];
|
||||
if (Buffer.isBuffer(str))
|
||||
{
|
||||
str.copy(buf, offset);
|
||||
offset += str.length;
|
||||
} else if(Array.isArray(str)) {
|
||||
for(var item of str) buf[offset++] = item;
|
||||
} else {
|
||||
// TODO: buffer.write could be faster
|
||||
for (var c = 0; c < str.length; ++c)
|
||||
|
|
|
|||
Loading…
Reference in a new issue