maraisr/object-identityPublic

readme.md

object-identity



npm add object-identity hashes objects

downloads size size

โšก Features

  • โœ… Intuitive

  • ๐ŸŒช Recursive/Circular support

  • ๐ŸŽ Performant โ€” TBD benchmarks

  • ๐Ÿชถ Lightweight โ€” a mere 503B and no dependencies.

๐Ÿš€ Usage

import { createHash } from 'node:crypto';
import { identify } from 'object-identity';

// ~> Some user defined hasher
const hasher = (value) => createHash('sha1').update(value).digest('hex');

// Lets hash the object
const hashA = identify({ a: "b" }, hasher);
const hashB = identify({ a: "b" }, hasher);

expect(hashA).toEqual(hashB);

License

MIT ยฉ Marais Rossouw