Permalink
Browse files

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

  • Loading branch information...
clayzermk1 committed Mar 7, 2013
1 parent 22d0402 commit 3e4fbae30057e9fff58ebfbc4b718ec760426bf0
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/bson/bson.js
View
@@ -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

0 comments on commit 3e4fbae

Please sign in to comment.