{"name":"hash-it","version":"7.0.2","keywords":["hash","hashcode","object-hash","unique"],"author":{"name":"planttheidea"},"license":"MIT","_id":"hash-it@7.0.2","maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"homepage":"https://github.com/planttheidea/hash-it#readme","bugs":{"url":"https://github.com/planttheidea/hash-it/issues"},"dist":{"shasum":"f97e8a6a94f4d8b93a5f038d6fb260d62949d77b","tarball":"http://registry-npm.ywwl.com/hash-it/download/hash-it-7.0.2.tgz","fileCount":32,"integrity":"sha512-LmxjXNePQBK8mFwDcWO9/lhTugWlE6OZRlC4zEwvoy0Ek8vFY09xNBVMGdKJyRQhUsIFRuUbk5izMzC5d3M7xA==","signatures":[{"sig":"MEYCIQC9D+3rQzR6xvZdOzR2TngdvfoSyyaSDbvtJO1rCjU4WQIhAOIA0g14nigOf7WFJE3AoFFCJVt7oztQWAq9pK8hJdvL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":127842,"size":20507,"noattachment":false,"key":"/hash-it/-/hash-it-7.0.2.tgz"},"main":"dist/cjs/index.cjs","type":"module","types":"./index.d.ts","module":"dist/es/index.mjs","browser":"dist/umd/index.js","exports":{".":{"import":{"types":"./dist/es/index.d.mts","default":"./dist/es/index.mjs"},"default":{"types":"./dist/umd/index.d.ts","default":"./dist/umd/index.js"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}}},"gitHead":"e667e4be034ff1fcd4d7f0bad72ebb55b416d2f0","scripts":{"dev":"vite --config=config/vite.config.ts","lint":"eslint --max-warnings=0","test":"vitest run --config=config/vitest.config.ts","build":"npm run clean && npm run build:dist && npm run build:types","clean":"rm -rf dist","start":"npm run dev","format":"prettier . --log-level=warn --write","clean:es":"rm -rf dist/es","benchmark":"npm run clean:es && npm run build:es && node benchmarks/index.js","clean:cjs":"rm -rf dist/cjs","clean:umd":"rm -rf dist/umd","typecheck":"tsc --noEmit","build:dist":"NODE_ENV=production rollup -c config/rollup.config.js","release:rc":"release-it --config=config/release-it/rc.json","build:types":"pti fix-types -l dist","format:check":"prettier . --log-level=warn --check","release:beta":"release-it --config=config/release-it/beta.json","release:alpha":"release-it --config=config/release-it/alpha.json","release:stable":"release-it --config=config/release-it/stable.json","release:scripts":"npm run format:check && npm run typecheck && npm run lint && npm run test && npm run build","benchmark:compare":"npm run build:esm && node benchmarks/compare.js"},"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"repository":{"url":"git+https://github.com/planttheidea/hash-it.git","type":"git"},"_npmVersion":"11.6.2","description":"Hash any object based on its value","directories":{},"resolutions":{"decompress-response":"^8.0.0"},"sideEffects":false,"_nodeVersion":"24.11.1","browserslist":["defaults","Explorer >= 9","Safari >= 6","Opera >= 15","iOS >= 8","Android >= 4"],"_hasShrinkwrap":false,"devDependencies":{"ora":"^9.0.0","vite":"^7.2.7","jsdom":"^27.3.0","react":"^19.2.3","eslint":"^9.39.1","rollup":"^4.53.3","vitest":"^4.0.15","prettier":"^3.7.4","benchmark":"^2.1.4","react-dom":"^19.2.3","prop-types":"^15.8.1","release-it":"^19.1.0","typescript":"^5.9.3","hash-object":"^5.0.1","object-hash":"^3.0.0","@types/jsdom":"^27.0.0","@types/react":"^19.2.7","@faker-js/faker":"^10.1.0","@types/react-dom":"^19.2.3","node-object-hash":"^3.1.1","@vitest/coverage-v8":"^4.0.15","@planttheidea/build-tools":"^1.2.3"},"_npmOperationalInternal":{"tmp":"tmp/hash-it_7.0.2_1765539532109_0.901751323717068","host":"s3://npm-registry-packages-npm-production"},"readme":"# hash-it\n\nFast and consistent hashCode for any object type\n\n## Table of contents\n\n- [hash-it](#hash-it)\n  - [Table of contents](#table-of-contents)\n  - [Usage](#usage)\n  - [Overview](#overview)\n  - [Guarantees](#guarantees)\n    - [Consistency](#consistency)\n    - [Equality](#equality)\n  - [Support](#support)\n  - [Development](#development)\n\n## Usage\n\n```javascript\n// ES2015\nimport { hash } from 'hash-it';\n\n// CommonJS\nconst { hash } = require('hash-it');\n\n// hash any standard object\nconsole.log(hash({ foo: 'bar' })); // 1663244226405536\n\n// or a circular object\nconsole.log(hash(window)); // 3557759737121602\n```\n\n## Overview\n\n`hash-it` has a simple goal: provide a fast, consistent, unique hashCode for any object type that is uniquely based on\nits values. This has a number of uses such as duplication prevention, equality comparisons, blockchain construction,\netc.\n\n_Any object type?_\n\nYes, any object type. Primitives, ES2015 classes like `Symbol`, DOM elements (yes, you can even hash the `window` object\nif you want). Any object type. Here is the list of object classes that produce consistent, unique hashes based on their\nvalue:\n\n- `Arguments`\n- `Array`\n- `ArrayBuffer`\n- `AsyncFunction` (based on `toString`)\n- `AsyncGeneratorFunction` (based on `toString`)\n- `BigInt`\n- `BigInt64Array`\n- `BigUint64Array`\n- `Boolean`\n- `DataView` (based on the bytes within its view window)\n- `Date` (based on `getTime`)\n- `DocumentFragment` (based on `outerHTML` of all `children`)\n- `Error` (based on `message` and `stack`)\n  - Includes all sub-types (e.g., `TypeError`, `ReferenceError`, etc.)\n- `Event` (based on all properties other than `Event.timeStamp` and `Event.srcElement`)\n  - Includes all sub-types (e.g., `MouseEvent`, `KeyboardEvent`, etc.)\n- `Float16Array`\n- `Float32Array`\n- `Float64Array`\n- `Function` (based on `toString`)\n- `GeneratorFunction` (based on `toString`)\n- `Int8Array`\n- `Int16Array`\n- `Int32Array`\n- `HTMLElement` (based on `outerHTML`)\n  - Includes all sub-types (e.g., `HTMLAnchorElement`, `HTMLDivElement`, etc.)\n- `Map` (order-agnostic)\n- `Null`\n- `Number`\n- `Object` (handles circular objects, order-agnostic)\n- `Proxy`\n- `RegExp`\n- `Set` (order-agnostic)\n- `SharedArrayBuffer`\n- `String`\n- `SVGElement` (based on `outerHTML`)\n  - Includes all sub-types (e.g., `SVGRectElement`, `SVGPolygonElement`, etc.)\n- `Symbol` (based on `toString`)\n- `Uint8Array`\n- `Uint8ClampedArray`\n- `Uint16Array`\n- `Uint32Array`\n- `Undefined`\n- `Window`\n\n_Are there any exceptions?_\n\nSadly, yes, there are a few scenarios where internal values cannot be introspected for the object. In this case, the\nobject is hashed based on its class type and reference.\n\n- `Promise`\n  - There is no way to synchronously obtain the values contained within due to its asynchronous nature\n- `Blob`\n  - Like `Promise`, there is no way to synchronously obtain the values contained within\n- `Generator` (the result of calling a `GeneratorFunction`)\n  - Like `Promise`, there is no way to obtain the values contained within due to its dynamic iterable nature\n- `WeakMap` / `WeakRef` / `WeakSet`\n  - The spec explicitly forbids iteration over them, so the unique values cannot be discovered\n\n```ts\nconst promise = Promise.resolve(123);\n\nconsole.log(hash(promise)); // 8959449433830577\nconsole.log(hash(promise)); // 8959449433830577\nconsole.log(hash(Promise.resolve(123))); // 2215269628940933\n```\n\nIf there is an object class or data type that is missing, please submit an issue.\n\n## Guarantees\n\n### Consistency\n\nWhile the hashes will be consistent when calculated within the same environment, there is no guarantee that the\nresulting hash will be the same across different environments due to environment-specific or browser-specific\nimplementations of features. This is limited to extreme edge cases, such as hashing the `window` object, but should be\nconsidered if being used with persistence over different environments.\n\nThe same applies across versions of `hash-it` itself: the value produced for a given input may change between releases\nas the algorithm is refined. Hashes are intended for comparison within a single running program, not for persistence.\n\n### Equality\n\nA few specifics are worth calling out:\n\n- `0` and `-0` produce the same hash, as do two `NaN` values, using\n  [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) comparison.\n- A hole in a sparse array is treated as `undefined`, so `[, ,]` and `[undefined, undefined]` produce the same hash.\n- Enumerable own properties added to an array beyond its indices are included in its hash, on the same terms as a plain\n  object.\n\n## Support\n\nAn ES2015 environment is required; the published bundles are emitted as ES2015 syntax and use ES2015 built-ins such as\n`WeakMap`.\n\n## Development\n\nClone the repo and dependencies via `yarn`. The npm scripts available:\n\n- `benchmark` => run benchmark of various data types\n- `benchmark:compare` => run benchmark of some data types comparing against other hashing modules\n- `build` => run `build:es`, `build:cjs`, and `build:umd` scripts\n- `build:cjs` => run rollup to build `cjs` files\n- `build:es` => run rollup to build `es` files\n- `build:umd` => run rollup to build `umd` files\n- `clean` => remove files produced from `build` script\n- `clean:cjs` => remove files produced from `build:cjs` script\n- `clean:es` => remove files produced from `build:es` script\n- `clean:umd` => remove files produced from `build:umd` script\n- `dev` => run dev server to run example app / playground\n- `format` => run `prettier` to format repo\n- `format:check` => run `prettier` to validate formatting in repo\n- `lint` => run ESLint against all files in the `src` folder\n- `lint:fix` => run `lint` script, automatically applying fixable changes\n- `release:alpha` => release a new `alpha` version under the `next` tag\n- `release:beta` => release a new `beta` version under the `next` tag\n- `release:rc` => release a new `rc` version under the `next` tag\n- `release:stable` => release a new stable version under the `latest` tag\n- `start` => alias for `dev` script\n- `test` => run jest test functions with `NODE_ENV=test`\n- `typecheck` => run `tsc` to validate internal typings\n","publish_time":1765539532243,"_cnpm_publish_time":1765539532243,"dist-tags":{"latest":"7.1.1","next":"7.0.0-rc.0"}}