Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added buffer support check when packing Code() and functions.

  • Loading branch information...
commit 3e4fbae30057e9fff58ebfbc4b718ec760426bf0 1 parent 22d0402
@clayzermk1 clayzermk1 authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/bson/bson.js
View
6 lib/bson/bson.js
@@ -727,7 +727,7 @@ var packElement = function(name, value, checkKeys, buffer, index, serializeFunct
buffer[index++] = (size >> 16) & 0xff;
buffer[index++] = (size >> 24) & 0xff;
// Write the string
- buffer.write(functionString, index, 'utf8');
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
// Update index
index = index + size - 1;
// Write zero
@@ -917,7 +917,7 @@ var packElement = function(name, value, checkKeys, buffer, index, serializeFunct
buffer[index++] = (codeSize >> 24) & 0xff;
// Write the string
- buffer.write(functionString, index, 'utf8');
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
// Update index
index = index + codeSize - 1;
// Write zero
@@ -960,7 +960,7 @@ var packElement = function(name, value, checkKeys, buffer, index, serializeFunct
buffer[index++] = (size >> 16) & 0xff;
buffer[index++] = (size >> 24) & 0xff;
// Write the string
- buffer.write(functionString, index, 'utf8');
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
// Update index
index = index + size - 1;
// Write zero
Please sign in to comment.
Something went wrong with that request. Please try again.