Lightweight standalone ObjectID constructor compatible with MongoDB BSON ObjectID API. v2.0.4 is stable; releases are infrequent. Features zero-dependency creation and parsing of ObjectIDs without mongodb/bson driver — ideal for browser or server-side apps that need ObjectID generation/comparison but not full MongoDB client. Provides full API parity with official BSON ObjectID including createFromTime, createFromHexString, isValid, getTimestamp, and immutable instances. Ships TypeScript types. Supports ESM and CJS.
npm install bson-objectidNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates ObjectID creation from different inputs, validation, equality, and timestamp extraction.
Either use ObjectID() without new or new ObjectID(); both produce same result.
Ensure argument is either an ObjectID instance or a 24-char hex string.
Use ObjectID.createFromHexString(hex) not id.createFromHexString(hex).
Use .toHexString() instead of .id for hex string.
Use ObjectID() without new, or ensure import is correct.
Call ObjectID() with or without arguments.
No dependency data recorded yet.