Extremely tiny package (253 bytes uncompressed) for no-side-effect attaching unique IDs to Javascript objects.
IDs are stored in a WeakMap, so there's no alteration of the object in question (therefore cannot affect
other code), but also without affecting GC.
Supports IDs only for objects (including functions and arrays). IDs are based on the object "pointer," not based on the data inside the object. If you need to hash other data structures, you'll need to use a different hashing library.
const a = {};
const b = {};
console.log(objectId(a));     // 1
console.log(objectId(b));     // 2
console.log(objectId(a));     // 1
console.log(objectId(null));  // 0Build:
npm run buildUnit tests:
npm run testUnit tests, refreshed live:
npm run watchPrepare for release (e.g. run tests and bump version number):
npm run releasePublish to npm:
npm publish