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 1.1.2 to 1.1.3

5

HISTORY.md

@@ -0,1 +1,6 @@

<a name="1.1.3"></a>
## [1.1.3](https://github.com/mongodb/js-bson/compare/v1.1.2...v1.1.3) (2019-11-09)
Reverts 1.1.2
<a name="1.1.2"></a>

@@ -2,0 +7,0 @@ ## [1.1.2](https://github.com/mongodb/js-bson/compare/v1.1.1...v1.1.2) (2019-11-08)

7

lib/bson/binary.js

@@ -43,2 +43,4 @@ /**

this._bsontype = 'Binary';
if (buffer instanceof Number) {

@@ -83,7 +85,2 @@ this.sub_type = buffer;

Object.defineProperty(Binary.prototype, '_bsontype', {
value: 'Binary',
writable: false
});
/**

@@ -90,0 +87,0 @@ * Updates this binary with byte_value.

@@ -11,2 +11,3 @@ /**

if (!(this instanceof Code)) return new Code(code, scope);
this._bsontype = 'Code';
this.code = code;

@@ -16,7 +17,2 @@ this.scope = scope;

Object.defineProperty(Code.prototype, '_bsontype', {
value: 'Code',
writable: false
});
/**

@@ -23,0 +19,0 @@ * @ignore

@@ -13,2 +13,3 @@ /**

this._bsontype = 'DBRef';
this.namespace = namespace;

@@ -19,7 +20,2 @@ this.oid = oid;

Object.defineProperty(DBRef.prototype, '_bsontype', {
value: 'DBRef',
writable: false
});
/**

@@ -26,0 +22,0 @@ * @ignore

@@ -184,10 +184,6 @@ 'use strict';

var Decimal128 = function(bytes) {
this._bsontype = 'Decimal128';
this.bytes = bytes;
};
Object.defineProperty(Decimal128.prototype, '_bsontype', {
value: 'Decimal128',
writable: false
});
/**

@@ -194,0 +190,0 @@ * Create a Decimal128 instance from a string representation

@@ -11,10 +11,6 @@ /**

this._bsontype = 'Double';
this.value = value;
}
Object.defineProperty(Double.prototype, '_bsontype', {
value: 'Double',
writable: false
});
/**

@@ -21,0 +17,0 @@ * Access the number value.

@@ -11,10 +11,6 @@ /**

this._bsontype = 'Int32';
this.value = value;
};
Object.defineProperty(Int32.prototype, '_bsontype', {
value: 'Int32',
writable: false
});
/**

@@ -21,0 +17,0 @@ * Access the number value.

@@ -46,2 +46,3 @@ // Licensed under the Apache License, Version 2.0 (the "License");

this._bsontype = 'Long';
/**

@@ -60,7 +61,2 @@ * @type {number}

Object.defineProperty(Long.prototype, '_bsontype', {
value: 'Long',
writable: false
});
/**

@@ -67,0 +63,0 @@ * Return the int value.

@@ -9,10 +9,7 @@ /**

if (!(this instanceof MaxKey)) return new MaxKey();
this._bsontype = 'MaxKey';
}
Object.defineProperty(MaxKey.prototype, '_bsontype', {
value: 'MaxKey',
writable: false
});
module.exports = MaxKey;
module.exports.MaxKey = MaxKey;

@@ -9,10 +9,7 @@ /**

if (!(this instanceof MinKey)) return new MinKey();
this._bsontype = 'MinKey';
}
Object.defineProperty(MinKey.prototype, '_bsontype', {
value: 'MinKey',
writable: false
});
module.exports = MinKey;
module.exports.MinKey = MinKey;

@@ -42,2 +42,4 @@ // Custom inspect property name / symbol.

this._bsontype = 'ObjectID';
// The most common usecase (blank id, new objectId instance)

@@ -80,7 +82,2 @@ if (id == null || typeof id === 'number') {

Object.defineProperty(ObjectID.prototype, '_bsontype', {
value: 'ObjectID',
writable: false
});
// Allow usage of ObjectId as well as ObjectID

@@ -87,0 +84,0 @@ // var ObjectId = ObjectID;

@@ -64,3 +64,2 @@ 'use strict';

}
var _bsontype, _objPrototype;

@@ -89,4 +88,2 @@ switch (typeof value) {

case 'object':
var _objPrototype = value && Object.getPrototypeOf(value)
var _bsontype = _objPrototype && _objPrototype._bsontype || undefined;
if (

@@ -96,7 +93,7 @@ value == null ||

value instanceof MaxKey ||
_bsontype === 'MinKey' ||
_bsontype === 'MaxKey'
value['_bsontype'] === 'MinKey' ||
value['_bsontype'] === 'MaxKey'
) {
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
} else if (value instanceof ObjectID || _bsontype === 'ObjectID' || _bsontype === 'ObjectId') {
} else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);

@@ -113,10 +110,10 @@ } else if (value instanceof Date || isDate(value)) {

value instanceof Timestamp ||
_bsontype === 'Long' ||
_bsontype === 'Double' ||
_bsontype === 'Timestamp'
value['_bsontype'] === 'Long' ||
value['_bsontype'] === 'Double' ||
value['_bsontype'] === 'Timestamp'
) {
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
} else if (value instanceof Decimal128 || _bsontype === 'Decimal128') {
} else if (value instanceof Decimal128 || value['_bsontype'] === 'Decimal128') {
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
} else if (value instanceof Code || _bsontype === 'Code') {
} else if (value instanceof Code || value['_bsontype'] === 'Code') {
// Calculate size depending on the availability of a scope

@@ -142,3 +139,3 @@ if (value.scope != null && Object.keys(value.scope).length > 0) {

}
} else if (value instanceof Binary || _bsontype === 'Binary') {
} else if (value instanceof Binary || value['_bsontype'] === 'Binary') {
// Check what kind of subtype we have

@@ -155,3 +152,3 @@ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {

}
} else if (value instanceof Symbol || _bsontype === 'Symbol') {
} else if (value instanceof Symbol || value['_bsontype'] === 'Symbol') {
return (

@@ -164,3 +161,3 @@ (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +

);
} else if (value instanceof DBRef || _bsontype === 'DBRef') {
} else if (value instanceof DBRef || value['_bsontype'] === 'DBRef') {
// Set up correct object for serialization

@@ -196,3 +193,3 @@ var ordered_values = {

);
} else if (value instanceof BSONRegExp || _bsontype === 'BSONRegExp') {
} else if (value instanceof BSONRegExp || value['_bsontype'] === 'BSONRegExp') {
return (

@@ -199,0 +196,0 @@ (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +

@@ -708,5 +708,2 @@ 'use strict';

var type = typeof value;
var _objPrototype = value && type === 'object' && Object.getPrototypeOf(value)
var _bsontype = _objPrototype && _objPrototype._bsontype || undefined;
if (type === 'string') {

@@ -724,3 +721,3 @@ index = serializeString(buffer, key, value, index, true);

index = serializeNull(buffer, key, value, index, true);
} else if (_bsontype === 'ObjectID' || _bsontype === 'ObjectId') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index, true);

@@ -731,3 +728,3 @@ } else if (Buffer.isBuffer(value)) {

index = serializeRegExp(buffer, key, value, index, true);
} else if (type === 'object' && _bsontype == null) {
} else if (type === 'object' && value['_bsontype'] == null) {
index = serializeObject(

@@ -745,7 +742,7 @@ buffer,

);
} else if (type === 'object' && _bsontype === 'Decimal128') {
} else if (type === 'object' && value['_bsontype'] === 'Decimal128') {
index = serializeDecimal128(buffer, key, value, index, true);
} else if (_bsontype === 'Long' || _bsontype === 'Timestamp') {
} else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') {
index = serializeLong(buffer, key, value, index, true);
} else if (_bsontype === 'Double') {
} else if (value['_bsontype'] === 'Double') {
index = serializeDouble(buffer, key, value, index, true);

@@ -763,3 +760,3 @@ } else if (typeof value === 'function' && serializeFunctions) {

);
} else if (_bsontype === 'Code') {
} else if (value['_bsontype'] === 'Code') {
index = serializeCode(

@@ -776,16 +773,14 @@ buffer,

);
} else if (_bsontype === 'Binary') {
} else if (value['_bsontype'] === 'Binary') {
index = serializeBinary(buffer, key, value, index, true);
} else if (_bsontype === 'Symbol') {
} else if (value['_bsontype'] === 'Symbol') {
index = serializeSymbol(buffer, key, value, index, true);
} else if (_bsontype === 'DBRef') {
} else if (value['_bsontype'] === 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true);
} else if (_bsontype === 'BSONRegExp') {
} else if (value['_bsontype'] === 'BSONRegExp') {
index = serializeBSONRegExp(buffer, key, value, index, true);
} else if (_bsontype === 'Int32') {
} else if (value['_bsontype'] === 'Int32') {
index = serializeInt32(buffer, key, value, index, true);
} else if (_bsontype === 'MinKey' || _bsontype === 'MaxKey') {
} else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') {
index = serializeMinMax(buffer, key, value, index, true);
} else if (typeof value['_bsontype'] !== 'undefined') {
throw new TypeError('Unrecognized or invalid _bsontype: ' + value['_bsontype']);
}

@@ -811,5 +806,2 @@ }

var _objPrototype = value && type === 'object' && Object.getPrototypeOf(value)
var _bsontype = _objPrototype && _objPrototype._bsontype || undefined;
// Check the key and throw error if it's illegal

@@ -843,3 +835,3 @@ if (typeof key === 'string' && ignoreKeys.indexOf(key) === -1) {

index = serializeNull(buffer, key, value, index);
} else if (_bsontype === 'ObjectID' || _bsontype === 'ObjectId') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index);

@@ -850,3 +842,3 @@ } else if (Buffer.isBuffer(value)) {

index = serializeRegExp(buffer, key, value, index);
} else if (type === 'object' && _bsontype == null) {
} else if (type === 'object' && value['_bsontype'] == null) {
index = serializeObject(

@@ -864,9 +856,9 @@ buffer,

);
} else if (type === 'object' && _bsontype === 'Decimal128') {
} else if (type === 'object' && value['_bsontype'] === 'Decimal128') {
index = serializeDecimal128(buffer, key, value, index);
} else if (_bsontype === 'Long' || _bsontype === 'Timestamp') {
} else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') {
index = serializeLong(buffer, key, value, index);
} else if (_bsontype === 'Double') {
} else if (value['_bsontype'] === 'Double') {
index = serializeDouble(buffer, key, value, index);
} else if (_bsontype === 'Code') {
} else if (value['_bsontype'] === 'Code') {
index = serializeCode(

@@ -884,16 +876,14 @@ buffer,

index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if (_bsontype === 'Binary') {
} else if (value['_bsontype'] === 'Binary') {
index = serializeBinary(buffer, key, value, index);
} else if (_bsontype === 'Symbol') {
} else if (value['_bsontype'] === 'Symbol') {
index = serializeSymbol(buffer, key, value, index);
} else if (_bsontype === 'DBRef') {
} else if (value['_bsontype'] === 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions);
} else if (_bsontype === 'BSONRegExp') {
} else if (value['_bsontype'] === 'BSONRegExp') {
index = serializeBSONRegExp(buffer, key, value, index);
} else if (_bsontype === 'Int32') {
} else if (value['_bsontype'] === 'Int32') {
index = serializeInt32(buffer, key, value, index);
} else if (_bsontype === 'MinKey' || _bsontype === 'MaxKey') {
} else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') {
index = serializeMinMax(buffer, key, value, index);
} else if (typeof value['_bsontype'] !== 'undefined') {
throw new TypeError('Unrecognized or invalid _bsontype: ' + value['_bsontype']);
}

@@ -922,5 +912,2 @@ }

var _objPrototype = value && type === 'object' && Object.getPrototypeOf(value)
var _bsontype = _objPrototype && _objPrototype._bsontype || undefined;
// Check the key and throw error if it's illegal

@@ -955,3 +942,3 @@ if (typeof key === 'string' && ignoreKeys.indexOf(key) === -1) {

index = serializeNull(buffer, key, value, index);
} else if (_bsontype === 'ObjectID' || _bsontype === 'ObjectId') {
} else if (value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
index = serializeObjectId(buffer, key, value, index);

@@ -962,3 +949,3 @@ } else if (Buffer.isBuffer(value)) {

index = serializeRegExp(buffer, key, value, index);
} else if (type === 'object' && _bsontype == null) {
} else if (type === 'object' && value['_bsontype'] == null) {
index = serializeObject(

@@ -976,9 +963,9 @@ buffer,

);
} else if (type === 'object' && _bsontype === 'Decimal128') {
} else if (type === 'object' && value['_bsontype'] === 'Decimal128') {
index = serializeDecimal128(buffer, key, value, index);
} else if (_bsontype === 'Long' || _bsontype === 'Timestamp') {
} else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') {
index = serializeLong(buffer, key, value, index);
} else if (_bsontype === 'Double') {
} else if (value['_bsontype'] === 'Double') {
index = serializeDouble(buffer, key, value, index);
} else if (_bsontype === 'Code') {
} else if (value['_bsontype'] === 'Code') {
index = serializeCode(

@@ -996,16 +983,14 @@ buffer,

index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions);
} else if (_bsontype === 'Binary') {
} else if (value['_bsontype'] === 'Binary') {
index = serializeBinary(buffer, key, value, index);
} else if (_bsontype === 'Symbol') {
} else if (value['_bsontype'] === 'Symbol') {
index = serializeSymbol(buffer, key, value, index);
} else if (_bsontype === 'DBRef') {
} else if (value['_bsontype'] === 'DBRef') {
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions);
} else if (_bsontype === 'BSONRegExp') {
} else if (value['_bsontype'] === 'BSONRegExp') {
index = serializeBSONRegExp(buffer, key, value, index);
} else if (_bsontype === 'Int32') {
} else if (value['_bsontype'] === 'Int32') {
index = serializeInt32(buffer, key, value, index);
} else if (_bsontype === 'MinKey' || _bsontype === 'MaxKey') {
} else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') {
index = serializeMinMax(buffer, key, value, index);
} else if (typeof value['_bsontype'] !== 'undefined') {
throw new TypeError('Unrecognized or invalid _bsontype: ' + value['_bsontype']);
}

@@ -1012,0 +997,0 @@ }

@@ -11,2 +11,3 @@ /**

// Execute
this._bsontype = 'BSONRegExp';
this.pattern = pattern || '';

@@ -32,8 +33,3 @@ this.options = options || '';

Object.defineProperty(BSONRegExp.prototype, '_bsontype', {
value: 'BSONRegExp',
writable: false
});
module.exports = BSONRegExp;
module.exports.BSONRegExp = BSONRegExp;

@@ -14,10 +14,6 @@ // Custom inspect property name / symbol.

if (!(this instanceof Symbol)) return new Symbol(value);
this._bsontype = 'Symbol';
this.value = value;
}
Object.defineProperty(Symbol.prototype, '_bsontype', {
value: 'Symbol',
writable: false
});
/**

@@ -24,0 +20,0 @@ * Access the wrapped string value.

@@ -47,2 +47,3 @@ // Licensed under the Apache License, Version 2.0 (the "License");

if (!(this instanceof Timestamp)) return new Timestamp(low, high);
this._bsontype = 'Timestamp';
/**

@@ -61,7 +62,2 @@ * @type {number}

Object.defineProperty(Timestamp.prototype, '_bsontype', {
value: 'Timestamp',
writable: false
});
/**

@@ -68,0 +64,0 @@ * Return the int value.

@@ -15,3 +15,3 @@ {

],
"version": "1.1.2",
"version": "1.1.3",
"author": "Christian Amor Kvalheim <christkv@gmail.com>",

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

Sorry, the diff of this file is too big to display

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