Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bson

Package Overview
Dependencies
Maintainers
2
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bson - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

36

lib/bson/bson.js

@@ -1,2 +0,2 @@

"use strict"
// "use strict"

@@ -25,27 +25,10 @@ var writeIEEE754 = require('./float_parser').writeIEEE754

*/
// Max Size
var MAXSIZE = (1024*1024*17);
// Max Document Buffer size
var buffer = new Buffer(1024 * 64);
var buffer = new Buffer(MAXSIZE);
var BSON = function() {
this.buffer = buffer;
}
// Handle range errors, allowing buffer to grow over time
var attemptSerialize = function(self, object, checkKeys, asBuffer, serializeFunctions, index) {
try {
// Serialize into the buffer
return serializer(self.buffer, object, checkKeys, index || 0, 0, serializeFunctions);
} catch(err) {
// Range error, allocate more space
if(err instanceof RangeError) {
self.buffer = new Buffer(self.buffer.length * 2);
} else {
throw err;
}
// Attempt to serialize again
return attemptSerialize(self, object, checkKeys, asBuffer, serializeFunctions, index);
}
}
/**

@@ -63,7 +46,7 @@ * Serialize a Javascript object.

// Attempt to serialize
var serializationIndex = attemptSerialize(this, object, checkKeys, asBuffer, serializeFunctions, index);
var serializationIndex = serializer(buffer, object, checkKeys, index || 0, 0, serializeFunctions);
// Create the final buffer
var finishedBuffer = new Buffer(serializationIndex);
// Copy into the finished buffer
this.buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
// Return the buffer

@@ -84,6 +67,7 @@ return finishedBuffer;

*/
BSON.prototype.serializeWithBufferAndIndex = function(object, checkKeys, buffer, startIndex, serializeFunctions) {
BSON.prototype.serializeWithBufferAndIndex = function(object, checkKeys, finalBuffer, startIndex, serializeFunctions) {
// Attempt to serialize
var serializationIndex = attemptSerialize(this, object, checkKeys, true, serializeFunctions, 0);
this.buffer.copy(buffer, startIndex, 0, serializationIndex);
var serializationIndex = serializer(buffer, object, checkKeys, index || 0, 0, serializeFunctions);
buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
// Return the index
return startIndex + serializationIndex - 1;

@@ -90,0 +74,0 @@ }

@@ -556,3 +556,3 @@ "use strict"

} else if(type == 'object' && value['_bsontype'] == null) {
index = serializeObject(buffer, key, value, index, checkKeys, depth);
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Long' || value['_bsontype'] == 'Timestamp') {

@@ -563,5 +563,5 @@ index = serializeLong(buffer, key, value, index);

} else if(typeof value == 'function' && serializeFunctions) {
index = serializeFunction(buffer, key, value, index, checkKeys, depth);
index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Code') {
index = serializeCode(buffer, key, value, index, checkKeys, depth);
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Binary') {

@@ -572,3 +572,3 @@ index = serializeBinary(buffer, key, value, index);

} else if(value['_bsontype'] == 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth);
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions);
}

@@ -620,3 +620,3 @@ }

} else if(type == 'object' && value['_bsontype'] == null) {
index = serializeObject(buffer, key, value, index, checkKeys, depth);
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Long' || value['_bsontype'] == 'Timestamp') {

@@ -627,5 +627,5 @@ index = serializeLong(buffer, key, value, index);

} else if(value['_bsontype'] == 'Code') {
index = serializeCode(buffer, key, value, index, checkKeys, depth);
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(typeof value == 'function' && serializeFunctions) {
index = serializeFunction(buffer, key, value, index, checkKeys, depth);
index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Binary') {

@@ -636,3 +636,3 @@ index = serializeBinary(buffer, key, value, index);

} else if(value['_bsontype'] == 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth);
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions);
}

@@ -639,0 +639,0 @@ }

{ "name" : "bson"
, "description" : "A bson parser for node.js and the browser"
, "keywords" : ["mongodb", "bson", "parser"]
, "version" : "0.4.4"
, "version" : "0.4.5"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"

@@ -6,0 +6,0 @@ , "contributors" : []

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc