A utility library for decoding MongoDB change stream resume tokens into their constituent components. Current stable version is 1.1.2, with an irregular release cadence focused on maintenance. It provides a simple decode function that extracts fields such as timestamp, version, tokenType, txnOpIndex, fromInvalidate, uuid, and documentKey from a hex-encoded resume token string. It also ships as a CLI via npx. Compared to manual parsing, this library handles the binary encoding details and BSON type mapping, reducing errors and development time.
npm install mongodb-resumetoken-decoderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Decodes a hex-encoded MongoDB change stream resume token into its components using the default export.
Wrap the decoder in a try/catch when using user-provided tokens.
If you rely on JSON serialization, use a replacer function for Timestamp and UUID.
Use npx as documented; do not count on the binary being on PATH after npm install -g.
Avoid using in hot paths or offload to worker threads if performance is critical.
Use 'import decode from ...' or 'const decode = require(...)'
Ensure the token is a full hex string from MongoDB changestream resume token.
Check that the token is defined before calling decode(token)