Skip to content

Latest commit

 

History

History

README.md

W5S Unique identifier of object-like values (object, symbol, function) (@w5s/object-id)

NPM Version License

This package can be used to generate a unique identifier (number) for an object / function / symbol. This kind of numeric identifier can be used to compute hash, generate debug trace, etc.

Installation

npm install @w5s/object-id

Usage

import { objectId } from '@w5s/object-id';

export function main(): void {
  const someObject = { foo: 1 };
  const id = objectId(someObject); // typeof id === 'number'
  console.log(id === objectId(someObject)); // true (because idempotent)
}

License

MIT © Julien Polo julien.polo@gmail.com