{"name":"hash-it","version":"6.0.1","keywords":["hash","hashcode","object-hash","unique"],"author":{"name":"planttheidea"},"license":"MIT","_id":"hash-it@6.0.1","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":"285fd4cbab97c880d1889240a35561fa71703664","tarball":"http://registry-npm.ywwl.com/hash-it/download/hash-it-6.0.1.tgz","fileCount":40,"integrity":"sha512-qhl8+l4Zwi1eLlL3lja5ywmDQnBzLEJxd0QJoAVIgZpgQbdtVZrN5ypB0y3VHwBlvAalpcbM2/A6x7oUks5zNg==","signatures":[{"sig":"MEUCIQDTO9RjgGqHsBwXPoy3HFPFB90sj29LiHnAtASQKe5+dgIgXES6jzddIeRR6M7DTf12mSWU+8B9CGkVFOZVQNxhVRg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":149273,"size":23223,"noattachment":false,"key":"/hash-it/-/hash-it-6.0.1.tgz"},"main":"dist/cjs/index.cjs","type":"module","types":"./index.d.ts","module":"dist/esm/index.mjs","browser":"dist/umd/index.js","exports":{".":{"import":{"types":"./dist/esm/types/index.d.mts","default":"./dist/esm/index.mjs"},"default":{"types":"./dist/umd/types/index.d.ts","default":"./dist/umd/index.js"},"require":{"types":"./dist/cjs/types/index.d.cts","default":"./dist/cjs/index.cjs"}}},"gitHead":"f4ad18d35965ed2cbc5dcaed595eca9ba3a5829c","scripts":{"dev":"NODE_ENV=development webpack serve --progress --config=build/webpack.config.js","lint":"NODE_ENV=test eslint src","test":"vitest run","build":"npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:min","clean":"rimraf dist","start":"npm run dev","release":"release-it","lint:fix":"npm run lint -- --fix","benchmark":"npm run build:esm && node benchmarks/index.js","build:cjs":"rimraf dist/cjs && NODE_ENV=production rollup -c build/rollup/config.cjs.js && tsc -p ./build/tsconfig/cjs.json && node scripts/create-cts-files.js","build:esm":"rimraf dist/esm && NODE_ENV=production rollup -c build/rollup/config.esm.js && tsc -p ./build/tsconfig/esm.json && node scripts/create-mts-files.js","build:min":"rimraf dist/min && NODE_ENV=production rollup -c build/rollup/config.min.js && tsc -p ./build/tsconfig/min.json","build:umd":"rimraf dist/umd && NODE_ENV=production rollup -c build/rollup/config.umd.js && tsc -p ./build/tsconfig/umd.json","typecheck":"tsc --noEmit","test:watch":"vitest","release:beta":"release-it --config=.release-it.beta.json","test:coverage":"vitest run -- --coverage","release:scripts":"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.0","description":"Hash any object based on its value","directories":{},"resolutions":{"decompress-response":"^8.0.0"},"_nodeVersion":"24.8.0","browserslist":["defaults","Explorer >= 9","Safari >= 6","Opera >= 15","iOS >= 8","Android >= 4"],"_hasShrinkwrap":false,"devDependencies":{"ora":"^6.3.1","husky":"^8.0.3","jsdom":"^27.2.0","react":"^18.3.1","tslib":"^2.8.1","eslint":"^8.57.1","rimraf":"^3.0.2","rollup":"^3.29.5","vitest":"^4.0.8","webpack":"^5.102.1","benchmark":"^2.1.4","react-dom":"^18.3.1","ts-loader":"^9.5.4","prop-types":"^15.8.1","release-it":"^19.0.6","typescript":"^4.9.5","hash-object":"^0.1.7","object-hash":"^3.0.0","webpack-cli":"^5.1.4","@types/jsdom":"^27.0.0","@types/react":"^18.3.26","@faker-js/faker":"^7.6.0","@types/react-dom":"^18.3.7","node-object-hash":"^2.3.10","webpack-dev-server":"^4.15.2","@vitest/coverage-v8":"4.0.8","html-webpack-plugin":"^5.6.4","@rollup/plugin-terser":"^0.3.0","eslint-webpack-plugin":"^3.2.0","@rollup/plugin-replace":"^5.0.7","@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-typescript":"^11.1.6","@typescript-eslint/parser":"^5.62.0","eslint-friendly-formatter":"^4.0.1","@rollup/plugin-node-resolve":"^15.3.1","@typescript-eslint/eslint-plugin":"^5.62.0"},"_npmOperationalInternal":{"tmp":"tmp/hash-it_6.0.1_1763068838380_0.5201326007114069","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":1763068838558,"_cnpm_publish_time":1763068838558,"dist-tags":{"latest":"7.1.1","next":"7.0.0-rc.0"}}