{"name":"hash-it","version":"7.0.0-beta.0","keywords":["hash","hashcode","object-hash","unique"],"author":{"name":"planttheidea"},"license":"MIT","_id":"hash-it@7.0.0-beta.0","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":"e57107ab88827bc16b95081db186e2025c0b5537","tarball":"http://registry-npm.ywwl.com/hash-it/download/hash-it-7.0.0-beta.0.tgz","fileCount":40,"integrity":"sha512-9zWCSYMp13tN4R3rh0R4ewza90oRkGev4raJO17TqW6xmCnJjJW92S1Htl/l+OUII1qFe4/VV1kul/jKergSog==","signatures":[{"sig":"MEUCIQD7ghz4S+tRljJv4Y6r3cNggyQAO/7GxJqM3fm1QjK5jQIgT31bAb1MPEzIW4Wu+PcClm6xLtXtQP8PGvJHZs2Ugx0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":147492,"size":23137,"noattachment":false,"key":"/hash-it/-/hash-it-7.0.0-beta.0.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":"eea694fd9248731e6f363fabe05ee3ee49a16085","scripts":{"dev":"vite --config=build/vite.config.js","lint":"eslint","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,"readmeFilename":"README.md","devDependencies":{"ora":"^9.0.0","vite":"^7.2.2","husky":"^9.1.7","jsdom":"^27.2.0","react":"^19.2.0","eslint":"^9.39.1","rimraf":"^6.1.0","rollup":"^4.53.2","vitest":"^4.0.9","benchmark":"^2.1.4","react-dom":"^19.2.0","prop-types":"^15.8.1","release-it":"^19.0.6","typescript":"^5.9.3","hash-object":"^5.0.1","object-hash":"^3.0.0","@types/jsdom":"^27.0.0","@types/react":"^19.2.5","@faker-js/faker":"^10.1.0","@types/react-dom":"^19.2.3","node-object-hash":"^3.1.1","typescript-eslint":"^8.46.4","@vitest/coverage-v8":"^4.0.9","eslint-plugin-import":"^2.32.0","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-replace":"^6.0.3","@rollup/plugin-commonjs":"^29.0.0","@rollup/plugin-typescript":"^12.3.0","@typescript-eslint/parser":"^8.46.4","eslint-friendly-formatter":"^4.0.1","@rollup/plugin-node-resolve":"^16.0.3","@typescript-eslint/eslint-plugin":"^8.46.4"},"_npmOperationalInternal":{"tmp":"tmp/hash-it_7.0.0-beta.0_1763244988022_0.7955383326892242","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":1763244988236,"_cnpm_publish_time":1763244988236,"dist-tags":{"latest":"7.1.1","next":"7.0.0-rc.0"}}