Socket
Socket
Sign inDemoInstall

bson

Package Overview
Dependencies
Maintainers
4
Versions
162
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 2.0.0 to 2.0.1

15

HISTORY.md

@@ -0,1 +1,16 @@

<a name="2.0.1"></a>
## [2.0.1](https://github.com/mongodb/js-bson/compare/v2.0.0...v2.0.1) (2018-02-28)
### Bug Fixes
* **serializer:** ensure RegExp options are alphabetically sorted ([d60659d](https://github.com/mongodb/js-bson/commit/d60659d))
### Features
* **db-ref:** support passing a namespace into a DBRef ctor ([604831b](https://github.com/mongodb/js-bson/commit/604831b))
<a name="2.0.0"></a>

@@ -2,0 +17,0 @@ # 2.0.0 (2018-02-26)

@@ -14,2 +14,9 @@ 'use strict';

// check if namespace has been provided
var parts = collection.split('.');
if (parts.length === 2) {
db = parts.shift();
collection = parts.shift();
}
this._bsontype = 'DBRef';

@@ -16,0 +23,0 @@ this.collection = collection;

166

lib/bson/objectid.js

@@ -14,6 +14,7 @@ 'use strict';

var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
var hasBufferType = false;
// Check if buffer exists
try {
if (Buffer && Buffer.from) var hasBufferType = true;
if (Buffer && Buffer.from) hasBufferType = true;
} catch (err) {

@@ -24,9 +25,9 @@ hasBufferType = false;

/**
* Create a new ObjectID instance
*
* @class
* @param {(string|number)} id Can be a 24 byte hex string, 12 byte binary string or a Number.
* @property {number} generationTime The generation time of this ObjectId instance
* @return {ObjectID} instance of ObjectID.
*/
* Create a new ObjectID instance
*
* @class
* @param {(string|number)} id Can be a 24 byte hex string, 12 byte binary string or a Number.
* @property {number} generationTime The generation time of this ObjectId instance
* @return {ObjectID} instance of ObjectID.
*/
var ObjectID = function ObjectID(id) {

@@ -86,7 +87,7 @@ // Duck-typing to support ObjectId from different npm packages

/**
* Return the ObjectID id as a 24 byte hex string representation
*
* @method
* @return {string} return the 24 byte hex string representation.
*/
* Return the ObjectID id as a 24 byte hex string representation
*
* @method
* @return {string} return the 24 byte hex string representation.
*/
ObjectID.prototype.toHexString = function() {

@@ -119,8 +120,8 @@ if (ObjectID.cacheHexString && this.__id) return this.__id;

/**
* Update the ObjectID index used in generating new ObjectID's on the driver
*
* @method
* @return {number} returns next index value.
* @ignore
*/
* Update the ObjectID index used in generating new ObjectID's on the driver
*
* @method
* @return {number} returns next index value.
* @ignore
*/
ObjectID.prototype.get_inc = function() {

@@ -131,8 +132,8 @@ return (ObjectID.index = (ObjectID.index + 1) % 0xffffff);

/**
* Update the ObjectID index used in generating new ObjectID's on the driver
*
* @method
* @return {number} returns next index value.
* @ignore
*/
* Update the ObjectID index used in generating new ObjectID's on the driver
*
* @method
* @return {number} returns next index value.
* @ignore
*/
ObjectID.prototype.getInc = function() {

@@ -143,8 +144,8 @@ return this.get_inc();

/**
* Generate a 12 byte id buffer used in ObjectID's
*
* @method
* @param {number} [time] optional parameter allowing to pass in a second based timestamp.
* @return {Buffer} return the 12 byte id buffer string.
*/
* Generate a 12 byte id buffer used in ObjectID's
*
* @method
* @param {number} [time] optional parameter allowing to pass in a second based timestamp.
* @return {Buffer} return the 12 byte id buffer string.
*/
ObjectID.prototype.generate = function(time) {

@@ -184,8 +185,8 @@ if ('number' !== typeof time) {

/**
* Converts the id into a 24 byte hex string for printing
*
* @param {String} format The Buffer toString format parameter.
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
* Converts the id into a 24 byte hex string for printing
*
* @param {String} format The Buffer toString format parameter.
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
ObjectID.prototype.toString = function(format) {

@@ -202,15 +203,15 @@ // Is the id a buffer then use the buffer toString method to return the format

/**
* Converts to a string representation of this Id.
*
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
* Converts to a string representation of this Id.
*
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
ObjectID.prototype.inspect = ObjectID.prototype.toString;
/**
* Converts to its JSON representation.
*
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
* Converts to its JSON representation.
*
* @return {String} return the 24 byte hex string representation.
* @ignore
*/
ObjectID.prototype.toJSON = function() {

@@ -221,11 +222,9 @@ return this.toHexString();

/**
* Compares the equality of this ObjectID with `otherID`.
*
* @method
* @param {object} otherID ObjectID instance to compare against.
* @return {boolean} the result of comparing two ObjectID's
*/
* Compares the equality of this ObjectID with `otherID`.
*
* @method
* @param {object} otherID ObjectID instance to compare against.
* @return {boolean} the result of comparing two ObjectID's
*/
ObjectID.prototype.equals = function equals(otherId) {
// var id;
if (otherId instanceof ObjectID) {

@@ -252,7 +251,7 @@ return this.toString() === otherId.toString();

/**
* Returns the generation date (accurate up to the second) that this ID was generated.
*
* @method
* @return {date} the generation date
*/
* Returns the generation date (accurate up to the second) that this ID was generated.
*
* @method
* @return {date} the generation date
*/
ObjectID.prototype.getTimestamp = function() {

@@ -266,9 +265,9 @@ var timestamp = new Date();

/**
* @ignore
*/
* @ignore
*/
ObjectID.index = ~~(Math.random() * 0xffffff);
/**
* @ignore
*/
* @ignore
*/
ObjectID.createPk = function createPk() {

@@ -279,8 +278,8 @@ return new ObjectID();

/**
* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
*
* @method
* @param {number} time an integer number representing a number of seconds.
* @return {ObjectID} return the created ObjectID
*/
* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
*
* @method
* @param {number} time an integer number representing a number of seconds.
* @return {ObjectID} return the created ObjectID
*/
ObjectID.createFromTime = function createFromTime(time) {

@@ -298,3 +297,2 @@ var buffer = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);

// Lookup tables
//var encodeLookup = '0123456789abcdef'.split('');
var decodeLookup = [];

@@ -311,8 +309,8 @@ i = 0;

/**
* Creates an ObjectID from a hex string representation of an ObjectID.
*
* @method
* @param {string} hexString create a ObjectID from a passed in 24 byte hexstring.
* @return {ObjectID} return the created ObjectID
*/
* Creates an ObjectID from a hex string representation of an ObjectID.
*
* @method
* @param {string} hexString create a ObjectID from a passed in 24 byte hexstring.
* @return {ObjectID} return the created ObjectID
*/
ObjectID.createFromHexString = function createFromHexString(string) {

@@ -342,7 +340,7 @@ // Throw an error if it's not a valid setup

/**
* Checks if a value is a valid bson ObjectId
*
* @method
* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise.
*/
* Checks if a value is a valid bson ObjectId
*
* @method
* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise.
*/
ObjectID.isValid = function isValid(id) {

@@ -376,4 +374,4 @@ if (id == null) return false;

/**
* @ignore
*/
* @ignore
*/
Object.defineProperty(ObjectID.prototype, 'generationTime', {

@@ -380,0 +378,0 @@ enumerable: true,

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

index = index + 12;
for (i = 0; i < namespace.length; i++) {

@@ -545,15 +544,4 @@ if (namespace.charCodeAt(i) === 0xfffd) {

// Split the namespace
var parts = namespace.split('.');
var db, collection;
if (parts.length === 2) {
db = parts.shift();
collection = parts.shift();
} else {
collection = namespace;
}
// Upgrade to DBRef type
object[name] = new DBRef(collection, oid, db);
object[name] = new DBRef(namespace, oid);
} else {

@@ -560,0 +548,0 @@ throw new Error(

@@ -204,4 +204,4 @@ 'use strict';

// Write the parameters
if (value.ignoreCase) buffer[index++] = 0x69; // i
if (value.global) buffer[index++] = 0x73; // s
if (value.ignoreCase) buffer[index++] = 0x69; // i
if (value.multiline) buffer[index++] = 0x6d; // m

@@ -208,0 +208,0 @@

'use strict';
function alphabetize(str) {
return str
.split('')
.sort()
.join('');
}
/**

@@ -14,3 +22,3 @@ * A class representation of the BSON RegExp type.

this.pattern = pattern || '';
this.options = options || '';
this.options = options ? alphabetize(options) : '';

@@ -17,0 +25,0 @@ // Validate options

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

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

@@ -18,0 +18,0 @@ "license": "Apache-2.0",

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

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