Comparing version 0.0.4 to 0.0.5
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
576153
11316
4