{"author":{"name":"planttheidea"},"browser":"dist/umd/index.js","browserslist":["defaults","Explorer >= 9","Safari >= 6","Opera >= 15","iOS >= 8","Android >= 4"],"bugs":{"url":"https://github.com/planttheidea/hash-it/issues"},"description":"Hash any object based on its value","devDependencies":{"@faker-js/faker":"^7.6.0","@rollup/plugin-commonjs":"^24.0.0","@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-replace":"^5.0.2","@rollup/plugin-terser":"^0.2.1","@rollup/plugin-typescript":"^10.0.1","@types/jest":"^29.2.4","@types/react":"^18.0.26","@types/react-dom":"^18.0.10","@typescript-eslint/eslint-plugin":"^5.47.1","@typescript-eslint/parser":"^5.47.1","benchmark":"^2.1.4","eslint":"^8.30.0","eslint-friendly-formatter":"^4.0.1","eslint-webpack-plugin":"^3.2.0","hash-object":"^0.1.7","html-webpack-plugin":"^5.5.0","husky":"^8.0.2","jest":"^29.3.1","jest-environment-jsdom":"^29.3.1","jest-expect-message":"^1.1.3","node-object-hash":"^2.3.10","object-hash":"^3.0.0","ora":"^6.1.2","prop-types":"^15.8.1","react":"^18.2.0","react-dom":"^18.2.0","release-it":"^15.6.0","rimraf":"^3.0.2","rollup":"^3.9.0","ts-jest":"^29.0.3","tslib":"^2.4.1","typescript":"^4.9.4","webpack":"^5.75.0","webpack-cli":"^5.0.1","webpack-dev-server":"^4.11.1"},"exports":{".":{"import":{"types":"./dist/esm/types/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/types/index.d.ts","default":"./dist/cjs/index.cjs"},"default":{"types":"./dist/umd/types/index.d.ts","default":"./dist/umd/index.js"}}},"homepage":"https://github.com/planttheidea/hash-it#readme","keywords":["hash","hashcode","object-hash","unique"],"license":"MIT","main":"dist/cjs/index.cjs","module":"dist/esm/index.mjs","name":"hash-it","repository":{"type":"git","url":"git+https://github.com/planttheidea/hash-it.git"},"resolutions":{"decompress-response":"^8.0.0"},"scripts":{"benchmark":"npm run build:esm && node benchmarks/index.js","benchmark:compare":"npm run build:esm && node benchmarks/compare.js","build":"npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:min","build:cjs":"rimraf dist/cjs && NODE_ENV=production rollup -c build/rollup/config.cjs.js && tsc -p ./build/tsconfig/cjs.json","build:esm":"rimraf dist/esm && NODE_ENV=production rollup -c build/rollup/config.esm.js && tsc -p ./build/tsconfig/esm.json","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","clean":"rimraf dist","dev":"NODE_ENV=development webpack serve --progress --config=build/webpack.config.js","lint":"NODE_ENV=test eslint src","lint:fix":"npm run lint -- --fix","release":"release-it","release:beta":"release-it --config=.release-it.beta.json","release:scripts":"npm run typecheck && npm run lint && npm run test && npm run build","start":"npm run dev","test":"NODE_ENV=test jest","test:coverage":"npm test -- --coverage","test:watch":"npm test -- --watch","typecheck":"tsc --noEmit"},"type":"module","types":"./index.d.ts","version":"6.0.0-beta.1","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  - [Equality methods](#equality-methods)\n    - [hash.is](#hashis)\n    - [hash.is.all](#hashisall)\n    - [hash.is.any](#hashisany)\n    - [hash.is.not](#hashisnot)\n  - [Note](#note)\n  - [Support](#support)\n    - [Browsers](#browsers)\n    - [Node](#node)\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' })); // 13729774857125\n\n// or a circular object\nconsole.log(hash(window)); // 3270731309314\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 its values. This has a number of uses such as duplication prevention, equality comparisons, blockchain construction, etc.\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 if you want). Any object type.\n\n_With no exceptions?_\n\nWell ... sadly, no, there are a few exceptions.\n\n- `Promise`\n  - There is no way to obtain the values contained within due to its asynchronous nature\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` / `WeakSet`\n  - The spec explicitly forbids iteration over them, so the unique values cannot be discovered\n\nIn each of these cases, no matter what the values of the object, they will always yield the same hash result, which is unique to each object type. If you have any ideas about how these can be uniquely hashed, they are welcome!\n\nHere is the list of object classes that produce unique hashes:\n\n- `Arguments`\n- `Array`\n- `ArrayBuffer`\n- `AsyncFunction` (based on `toString`)\n- `BigInt`\n- `Boolean`\n- `DataView` (based on its `buffer`)\n- `Date` (based on `getTime`)\n- `DocumentFragment` (based on `outerHTML` of all `children`)\n- `Error` (based on `stack`)\n  - Includes all sub-types (e.g., `TypeError`, `ReferenceError`, etc.)\n- `Event` (based on all properties other than `Event.timeStamp`)\n  - Includes all sub-types (e.g., `MouseEvent`, `KeyboardEvent`, etc.)\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- `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\nIf there is an object class or data type that is missing, please submit an issue.\n\n## Equality methods\n\n### hash.is\n\n`hash.is(value1: any, value2: any): boolean`\n\nCompares the two objects to determine equality.\n\n```javascript\nconsole.log(hash.is(null, 123)); // false\nconsole.log(hash.is(null, null)); // true\n```\n\n### hash.is.all\n\n`hash.is.all(value1: any, value2: any[, value3: any[, ...valueN]]): boolean`\n\nCompares the first object to all other objects passed to determine if all are equal based on hashCode\n\n```javascript\nconst foo = {\n  foo: 'bar',\n};\nconst alsoFoo = {\n  foo: 'bar',\n};\nconst stillFoo = {\n  foo: 'bar',\n};\n\nconsole.log(hash.is.all(foo, alsoFoo)); // true\nconsole.log(hash.is.all(foo, alsoFoo, stillFoo)); // true\n```\n\n### hash.is.any\n\n`hash.is.any(value1: any, value2: any[, value3: any[, ...valueN]]): boolean`\n\nCompares the first object to all other objects passed to determine if any are equal based on hashCode\n\n```javascript\nconst foo = {\n  foo: 'bar',\n};\nconst alsoFoo = {\n  foo: 'bar',\n};\nconst nopeBar = {\n  bar: 'baz',\n};\n\nconsole.log(hash.is.any(foo, alsoFoo)); // true\nconsole.log(hash.is.any(foo, nopeBar)); // false\nconsole.log(hash.is.any(foo, alsoFoo, nopeBar)); // true\n```\n\n### hash.is.not\n\n`hash.is.not(value1: any, value2: any): boolean`\n\nCompares the two objects to determine non-equality.\n\n```javascript\nconsole.log(hash.is.not(null, 123)); // true\nconsole.log(hash.is.not(null, null)); // false\n```\n\n## Note\n\nWhile the hashes will be consistent when calculated within the same environment, there is no guarantee that the resulting hash will be the same across different environments due to environment-specific or browser-specific implementations of features. This is limited to extreme edge cases, such as hashing the `window` object, but should be considered if being used with persistence over different environments.\n\n## Support\n\n### Browsers\n\n- Chrome (all versions)\n- Firefox (all versions)\n- Edge (all versions)\n- Opera 15+\n- IE 9+\n- Safari 6+\n- iOS 8+\n- Android 4+\n\n### Node\n\n- 4+\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 rollup to build ESM, CJS, and UMD files\n- `clean` => remove files produced from `build` script\n- `dev` => run webpack dev server to run example app / playground\n- `lint` => run ESLint against all files in the `src` folder\n- `lint:fix` => run `lint` script, automatically applying fixable changes\n- `prepublishOnly` => run `typecheck`, `lint`, `test`, and `build`\n- `start` => alias for `dev` script\n- `test` => run jest test functions with `NODE_ENV=test`\n- `test:coverage` => run `test` with coverage checker\n- `test:watch` => run `test` with persistent watcher\n- `typecheck` => run `tsc` to validate internal typings\n","readmeFilename":"README.md","gitHead":"2f30a9386d895b7f653d53772a8af5df449ace9b","_id":"hash-it@6.0.0-beta.1","_nodeVersion":"16.14.2","_npmVersion":"8.7.0","dist":{"integrity":"sha512-8QCU50rWr2sQ7aZ0DawmotPIQjkU+34e8TeZUa04RtaMRoKTQDkZh4yBFsk/tPUBTV1UW6fx3wBgUGYRlzDhlQ==","shasum":"19a190575dea542b44213f041abbaa0c18d1b099","tarball":"http://registry-npm.ywwl.com/hash-it/download/hash-it-6.0.0-beta.1.tgz","fileCount":54,"unpackedSize":147466,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4nhi+Us2/rlgfMG/LU2/qG0w6Wt+q0j6fHUZzTpqXTgIgb9QZbNQVzzepPWV0GWinkjSuUOmG+XNu7VyxX/RZzn4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrhRYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQsw/5AcsLgQXaoyA7xXafoXlwuiVBWa6iVMFLZSzMnjlg+3LTlK3X\r\nrPHSuRtoJbBBRe4WOEUsb3xor4tgY0E7iwp9sCEcvKGnJwzpCTqkriJBme4G\r\ncJNsKMvDparpcgNyze7FVttW+xxqx5k04HUVAyi+Bvzk18obItCtxxfJiqNj\r\nQKFDGd+uJ7iqvMueUnnHJfoKHJXAFPONtX8vlLW/03kzO2EhXAK7o7dzUtXk\r\nIkmFaudfKawdeKu5QLg6p1nSG7wOu/LOwODVBveBUD+zgfLJVb1gZKDp5AfL\r\nEklRokCdZdTFLXIxF3lbt98vP325NoRAh2D9cT4zgn4r3/KXPnywO8enNKEz\r\nHQsX2ZE/DVTZi8V7LcuFrxPmzqQcTJR6eWTqUYmUkOGAfgTpPh9hRKH6pTwq\r\n8MTU7QB11maFc5c/O4sV6e5+1UzoBWtBAG8IBYCcEFbyEIXXZaLvYqfxyjtC\r\nue6pPIZC5lGkhOFiG0mxpE39Www8SXreqhXssKyQqjOllqoAV3tTXp/ugbht\r\npH3tVY5OHlQLjqhss257duxXTxnglBYF4ED40cgc7R+3NnvCz29ocpoQ0JG4\r\naWSeQKPMu+Dh6ifioDAICt/BvU9/TAiIUBJJ9bzQy/q0bqw/cY+C6T1xnkvH\r\nOBysuitgjv9alLIY/+BkxsxYgpfCUjmZeBs=\r\n=4jwM\r\n-----END PGP SIGNATURE-----\r\n","size":23503,"noattachment":false,"key":"/hash-it/-/hash-it-6.0.0-beta.1.tgz"},"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"directories":{},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hash-it_6.0.0-beta.1_1672352856150_0.1806012835803179"},"_hasShrinkwrap":false,"publish_time":1672352856435,"_cnpm_publish_time":1672352856435,"dist-tags":{"latest":"7.1.1","next":"7.0.0-rc.0"}}