Caution 🚨: Be careful when you use shortObjectIdCache. All cache hooks are not stable outside the function.
shortObjectId — helps you to compress your ObjectId and make it short.
shortObjectIdCache — A predictable cache container instance, helps you to go and return between the shortObjetId number and the original ObjectId and subscribe to each shortObjectId (func) call.
When you pass cache: true inside the options object, you don't need to use shortObjectIdCache because it works on the background.
Usage
This is a practical example of how to use.
// you can also use the desctructure way .. const shortObjectId = require ('short-objectid'); // objectId <required> .. let mongodbObjectId = { "$oid" : "507f191e810c19729de860ea" }; // config object <optional> .. let config = { Timestamp: 57, MachineId: 65, ProcessId: 48, Counter: 47 }; // options object <optional> .. // you can pass one of these options [cache, keepOriginal] .. // cache option, informs the shortObjectId function that you // should subscribe to each call and then store all data .. let opts = { cache: true }; // Now you have access to 2 hooks (only with cache opts) // + getShortObjectId(fullObjectId: string): number // + getFullObjectId(shortObjectId: number): string