Skip to content

Commit 0d82bf2

Browse files
committed
fix: initialize counter with a random number from 1000 - 5000
1 parent aa2e6ee commit 0d82bf2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@
6161
// Generate a new custom ObjectId
6262
const timestampHex = Math.floor(Date.now() / 1000).toString(16).padStart(8, '0');
6363
const processIdHex = Math.floor(Math.random() * 0x100000000000).toString(16).padStart(12, '0');
64+
6465
counter = (counter + 1) % 10000;
66+
if (counter < 2) {
67+
counter = Math.floor(Math.random() * (5000 - 100 + 1)) + 100;
68+
}
69+
6570
const counterHex = counter.toString(16).padStart(4, '0');
6671

6772
// Return the custom ObjectId object with a toString() method

0 commit comments

Comments
 (0)