Permalink
Browse files

New: Made sure that Writer#bytes is always able to handle plain arrays

  • Loading branch information...
dcodeIO committed Jan 6, 2017
1 parent 9957b09 commit 4b786282a906387e071a5a28e4842a46df588c7d
Showing with 5 additions and 2 deletions.
  1. +1 −1 src/writer.js
  2. +4 −1 src/writer_buffer.js
@@ -121,7 +121,7 @@ function Writer() {
// list of operations to perform when finish() is called. This both allows us to allocate
// buffers of the exact required size and reduces the amount of work we have to do compared
// to first calculating over objects and then encoding over objects. In our case, the encoding
// part is just a linked list walk calling linked operations with already prepared values.
// part is just a linked list walk calling operations with already prepared values.
}
/**
@@ -36,7 +36,10 @@ var writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffe
}
/* istanbul ignore next */
: function writeBytesBuffer_copy(val, buf, pos) {
val.copy(buf, pos, 0, val.length);
if (val.copy)
val.copy(buf, pos, 0, val.length);
else for (var i = 0; i < val.length;)
buf[pos++] = val[i++];
};
/**

0 comments on commit 4b78628

Please sign in to comment.