Socket
Socket
Sign inDemoInstall

bson

Package Overview
Dependencies
0
Maintainers
2
Versions
162
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.12 to 0.4.13

lib/bson/map.js

3

lib/bson/index.js

@@ -10,2 +10,3 @@ try {

, './code'
, './map'
, './db_ref'

@@ -33,2 +34,3 @@ , './double'

, './code'
, './map'
, './db_ref'

@@ -60,2 +62,3 @@ , './double'

, './code'
, './map'
, './db_ref'

@@ -62,0 +65,0 @@ , './double'

@@ -6,2 +6,3 @@ "use strict"

Long = require('../long').Long,
Map = require('../map'),
Double = require('../double').Double,

@@ -531,3 +532,2 @@ Timestamp = require('../timestamp').Timestamp,

var type = typeof value;
if(type == 'string') {

@@ -571,2 +571,80 @@ index = serializeString(buffer, key, value, index);

}
} else if(object instanceof Map) {
var iterator = object.entries();
var done = false;
while(!done) {
// Unpack the next entry
var entry = iterator.next();
done = entry.done;
// Are we done, then skip and terminate
if(done) continue;
// Get the entry values
var key = entry.value[0];
var value = entry.value[1];
// Check the type of the value
var type = typeof value;
// Check the key and throw error if it's illegal
if(key != '$db' && key != '$ref' && key != '$id') {
if (key.match(regexp) != null) {
// The BSON spec doesn't allow keys with null bytes because keys are
// null-terminated.
throw Error("key " + key + " must not contain null bytes");
}
if (checkKeys) {
if('$' == key[0]) {
throw Error("key " + key + " must not start with '$'");
} else if (!!~key.indexOf('.')) {
throw Error("key " + key + " must not contain '.'");
}
}
}
// console.log("---------------------------------------------------")
// console.dir("key = " + key)
// console.dir("value = " + value)
if(type == 'string') {
index = serializeString(buffer, key, value, index);
} else if(type == 'number') {
index = serializeNumber(buffer, key, value, index);
} else if(type == 'boolean') {
index = serializeBoolean(buffer, key, value, index);
} else if(value instanceof Date || isDate(value)) {
index = serializeDate(buffer, key, value, index);
} else if(value === undefined && ignoreUndefined == true) {
} else if(value === null || value === undefined) {
index = serializeUndefined(buffer, key, value, index);
} else if(value['_bsontype'] == 'ObjectID') {
index = serializeObjectId(buffer, key, value, index);
} else if(Buffer.isBuffer(value)) {
index = serializeBuffer(buffer, key, value, index);
} else if(value instanceof RegExp || isRegExp(value)) {
index = serializeRegExp(buffer, key, value, index);
} else if(type == 'object' && value['_bsontype'] == null) {
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined);
} else if(value['_bsontype'] == 'Long' || value['_bsontype'] == 'Timestamp') {
index = serializeLong(buffer, key, value, index);
} else if(value['_bsontype'] == 'Double') {
index = serializeDouble(buffer, key, value, index);
} else if(value['_bsontype'] == 'Code') {
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined);
} else if(typeof value == 'function' && serializeFunctions) {
index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if(value['_bsontype'] == 'Binary') {
index = serializeBinary(buffer, key, value, index);
} else if(value['_bsontype'] == 'Symbol') {
index = serializeSymbol(buffer, key, value, index);
} else if(value['_bsontype'] == 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions);
} else if(value['_bsontype'] == 'BSONRegExp') {
index = serializeBSONRegExp(buffer, key, value, index);
} else if(value['_bsontype'] == 'MinKey' || value['_bsontype'] == 'MaxKey') {
index = serializeMinMax(buffer, key, value, index);
}
}
} else {

@@ -573,0 +651,0 @@ // Did we provide a custom serialization method

2

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc