Socket
Socket
Sign inDemoInstall

bson

Package Overview
Dependencies
Maintainers
2
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 0.0.4 to 0.0.5

89

lib/bson/objectid.js

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

this._bsontype = 'ObjectID';
var __id = null;

@@ -47,27 +48,29 @@ // Throw an error if it's not a valid setup

}
if(ObjectID.cacheHexString) this.__id = this.toHexString();
};
/**
* Returns the generation time in seconds that this ID was generated.
*
* @field generationTime
* @type {Number}
* @getter
* @setter
* @property return number of seconds in the timestamp part of the 12 byte id.
*/
Object.defineProperty(this, "generationTime", {
enumerable: true
, get: function () {
return Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true));
}
, set: function (value) {
var value = BinaryParser.encodeInt(value, 32, true, true);
this.id = value + this.id.substr(4);
delete this.__id;
this.toHexString();
}
});
/**
* Return the ObjectID id as a 24 byte hex string representation
*
* @return {String} return the 24 byte hex string representation.
* @api public
*/
ObjectID.prototype.toHexString = function() {
if(ObjectID.cacheHexString && this.__id) return this.__id;
var hexString = ''
, number
, value;
// internal hex representation for toHexString() speed
this.__id = _hex || this.toHexString();
for (var index = 0, len = this.id.length; index < len; index++) {
value = BinaryParser.toByte(this.id[index]);
number = value <= 15
? '0' + value.toString(16)
: value.toString(16);
hexString = hexString + number;
}
if(ObjectID.cacheHexString) this.__id = hexString;
return hexString;
};

@@ -121,26 +124,2 @@

/**
* Return the ObjectID id as a 24 byte hex string representation
*
* @return {String} return the 24 byte hex string representation.
* @api public
*/
ObjectID.prototype.toHexString = function() {
if(this.__id) return this.__id;
var hexString = ''
, number
, value;
for (var index = 0, len = this.id.length; index < len; index++) {
value = BinaryParser.toByte(this.id[index]);
number = value <= 15
? '0' + value.toString(16)
: value.toString(16);
hexString = hexString + number;
}
return this.__id = hexString;
};
/**
* Converts the id into a 24 byte hex string for printing

@@ -255,2 +234,18 @@ *

/**
* @ignore
*/
Object.defineProperty(ObjectID.prototype, "generationTime", {
enumerable: true
, get: function () {
return Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true));
}
, set: function (value) {
var value = BinaryParser.encodeInt(value, 32, true, true);
this.id = value + this.id.substr(4);
// delete this.__id;
this.toHexString();
}
});
/**
* Expose.

@@ -257,0 +252,0 @@ */

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

@@ -6,0 +6,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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc