Skip to content

Commit

Permalink
Fix generating 26 char id
Browse files Browse the repository at this point in the history
 - Fix pid sometimes being greater than 0xFFFF in a browser, causing generate() to return a 26-character id.

Fixes #6
  • Loading branch information
rahatarmanahmed committed Dec 1, 2015
1 parent df890be commit 417b3ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion objectid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

var MACHINE_ID = parseInt(Math.random() * 0xFFFFFF, 10);
var index = ObjectID.index = parseInt(Math.random() * 0xFFFFFF, 10);
var pid = typeof process === 'undefined' || typeof process.pid !== 'number' ? Math.floor(Math.random() * 100000) : process.pid % 0xFFFF;
var pid = typeof process === 'undefined' || (typeof process.pid !== 'number' ? Math.floor(Math.random() * 100000) : process.pid) % 0xFFFF;

/**
* Determine if an object is Buffer
Expand Down

0 comments on commit 417b3ba

Please sign in to comment.