Comparing version 0.2.2 to 0.2.3
var bson = null; | ||
// Load the precompiled win32 binary | ||
if(process.platform == "win32" && process.arch == "x64") { | ||
bson = require('./win32/x64/bson'); | ||
} else if(process.platform == "win32" && process.arch == "ia32") { | ||
bson = require('./win32/ia32/bson'); | ||
} else { | ||
bson = require('../build/Release/bson'); | ||
try { | ||
// Load the precompiled win32 binary | ||
if(process.platform == "win32" && process.arch == "x64") { | ||
bson = require('./win32/x64/bson'); | ||
} else if(process.platform == "win32" && process.arch == "ia32") { | ||
bson = require('./win32/ia32/bson'); | ||
} else { | ||
bson = require('../build/Release/bson'); | ||
} | ||
} catch(err) { | ||
console.error("Failed to load c++ bson extension, using pure JS version"); | ||
bson = require('../lib/bson/bson'); | ||
} | ||
@@ -11,0 +16,0 @@ |
@@ -25,4 +25,4 @@ /** | ||
*/ | ||
var ObjectID = function ObjectID(id, _hex) { | ||
if(!(this instanceof ObjectID)) return new ObjectID(id, _hex); | ||
var ObjectID = function ObjectID(id) { | ||
if(!(this instanceof ObjectID)) return new ObjectID(id); | ||
@@ -108,15 +108,11 @@ this._bsontype = 'ObjectID'; | ||
ObjectID.prototype.generate = function(time) { | ||
if ('number' == typeof time) { | ||
var time4Bytes = BinaryParser.encodeInt(time, 32, true, true); | ||
/* for time-based ObjectID the bytes following the time will be zeroed */ | ||
var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false); | ||
var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid); | ||
var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true); | ||
} else { | ||
var unixTime = parseInt(Date.now()/1000,10); | ||
var time4Bytes = BinaryParser.encodeInt(unixTime, 32, true, true); | ||
var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false); | ||
var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid); | ||
var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true); | ||
if ('number' != typeof time) { | ||
time = parseInt(Date.now()/1000,10); | ||
} | ||
var time4Bytes = BinaryParser.encodeInt(time, 32, true, true); | ||
/* for time-based ObjectID the bytes following the time will be zeroed */ | ||
var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false); | ||
var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid); | ||
var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true); | ||
@@ -185,3 +181,3 @@ return time4Bytes + machine3Bytes + pid2Bytes + index3Bytes; | ||
*/ | ||
ObjectID.index = 0; | ||
ObjectID.index = parseInt(Math.random() * 0xFFFFFF, 10); | ||
@@ -188,0 +184,0 @@ ObjectID.createPk = function createPk () { |
{ "name" : "bson" | ||
, "description" : "A bson parser for node.js and the browser" | ||
, "keywords" : ["mongodb", "bson", "parser"] | ||
, "version" : "0.2.2" | ||
, "version" : "0.2.3" | ||
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>" | ||
@@ -12,2 +12,5 @@ , "contributors" : [] | ||
, "url" : "https://github.com/mongodb/js-bson/issues" } | ||
, "dependencies": { | ||
"nan": "~0.4.1" | ||
} | ||
, "devDependencies": { | ||
@@ -26,4 +29,5 @@ "nodeunit": "0.7.3" | ||
} | ||
, "browser": "lib/bson/bson.js" | ||
, "licenses" : [ { "type" : "Apache License, Version 2.0" | ||
, "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 5 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
10984
6
1095308
1
46
+ Addednan@~0.4.1
+ Addednan@0.4.4(transitive)