diff --git a/src/writer.js b/src/writer.js index a9a8d9c64..17ff8089c 100644 --- a/src/writer.js +++ b/src/writer.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. } /** diff --git a/src/writer_buffer.js b/src/writer_buffer.js index 7167b7666..59ba327f8 100644 --- a/src/writer_buffer.js +++ b/src/writer_buffer.js @@ -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++]; }; /**