🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bson

Package Overview
Dependencies
Maintainers
2
Versions
174
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

to
0.2.3

build/binding.Makefile

19

ext/index.js
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