I am getting MongoDB ObjectIds, which are 12 bytes and their hex string looks like this: 62d34be4f8cd489f6d5b8e0e.
I want to use the object id as a map key like this:
new Map().set(ObjectId('62d34be4f8cd489f6d5b8e0e'),"value")
That doesn't really work because each ObjectId object is unique so two with the same id are not equal objects.
There are a few ways I can think of:
new Map().set("62d34be4f8cd489f6d5b8e0e", "value")
new Map().set(Buffer.from("62d34be4f8cd489f6d5b8e0e", "hex"), "value")
b�K���H�m[�\x0Enew Map().set(Buffer.from("62d34be4f8cd489f6d5b8e0e", "hex").toString(), "value")
new Map().set(Buffer.from("62d34be4f8cd489f6d5b8e0e", 'hex').readInt16BE(), "value")
Which method has the best performance?