{"id":13613213,"url":"https://github.com/planttheidea/hash-it","last_synced_at":"2025-05-16T14:05:54.524Z","repository":{"id":10105438,"uuid":"64434664","full_name":"planttheidea/hash-it","owner":"planttheidea","description":"Hash any object type based on its values","archived":false,"fork":false,"pushed_at":"2024-09-14T18:50:45.000Z","size":3682,"stargazers_count":209,"open_issues_count":4,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T00:16:22.186Z","etag":null,"topics":["hashcode","javascrpt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/planttheidea.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-28T23:24:30.000Z","updated_at":"2025-01-10T11:03:58.000Z","dependencies_parsed_at":"2023-02-18T20:00:28.531Z","dependency_job_id":"383306ff-a389-42d7-aa0e-9f1a01ece24d","html_url":"https://github.com/planttheidea/hash-it","commit_stats":{"total_commits":97,"total_committers":4,"mean_commits":24.25,"dds":0.3402061855670103,"last_synced_commit":"3e393b109b136e5be5f098401bc3ce0157208b0a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fhash-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fhash-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fhash-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fhash-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/planttheidea","download_url":"https://codeload.github.com/planttheidea/hash-it/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashcode","javascrpt"],"created_at":"2024-08-01T20:00:41.757Z","updated_at":"2025-05-16T14:05:54.503Z","avatar_url":"https://github.com/planttheidea.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","JavaScript"],"sub_categories":[],"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  - [Hash consistency](#hash-consistency)\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. Here is the list of object classes that produce consistent, unique hashes based on their value:\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 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- `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 object is hashed based on its class type and reference.\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` / `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)); // 16843037491939\nconsole.log(hash(promise)); // 16843037491939\nconsole.log(hash(Promise.resolve(123))); // 4622327363876\n```\n\nIf there is an object class or data type that is missing, please submit an issue.\n\n## Hash consistency\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` =\u003e run benchmark of various data types\n- `benchmark:compare` =\u003e run benchmark of some data types comparing against other hashing modules\n- `build` =\u003e run rollup to build ESM, CJS, and UMD files\n- `clean` =\u003e remove files produced from `build` script\n- `dev` =\u003e run webpack dev server to run example app / playground\n- `lint` =\u003e run ESLint against all files in the `src` folder\n- `lint:fix` =\u003e run `lint` script, automatically applying fixable changes\n- `prepublishOnly` =\u003e run `typecheck`, `lint`, `test`, and `build`\n- `start` =\u003e alias for `dev` script\n- `test` =\u003e run jest test functions with `NODE_ENV=test`\n- `test:coverage` =\u003e run `test` with coverage checker\n- `test:watch` =\u003e run `test` with persistent watcher\n- `typecheck` =\u003e run `tsc` to validate internal typings\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanttheidea%2Fhash-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanttheidea%2Fhash-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanttheidea%2Fhash-it/lists"}