Gathering detailed insights and metrics for hash-it
Gathering detailed insights and metrics for hash-it
Gathering detailed insights and metrics for hash-it
Gathering detailed insights and metrics for hash-it
@types/hash-it
Stub TypeScript definitions entry for hash-it, which provides its own types definitions
@monoblog/change-hash
Monoblog CLI that fetches the latest updated timestamp and makes it into a hash
@hashup-it/hashup-react-sdk
This is official HashUp protocol SDK for React. You can use it to make your own marketplace using our protocol.
hash-detectjs
detect-hash is a JavaScript module that allows you to detect the algorithm used to produce a hash. It works by matching the hash against a list of regular expressions and hash algorithms, and returns a list of possible algorithms that the hash could have
npm install hash-it
Typescript
Module System
Node Version
NPM Version
99.2
Supply Chain
100
Quality
76.2
Maintenance
100
Vulnerability
100
License
TypeScript (74.19%)
JavaScript (25.81%)
Total Downloads
37,876,010
Last Day
12,604
Last Week
394,161
Last Month
1,695,335
Last Year
16,269,810
MIT License
209 Stars
116 Commits
13 Forks
4 Watchers
9 Branches
4 Contributors
Updated on Jan 10, 2025
Minified
Minified + Gzipped
Latest Version
6.0.0
Package Id
hash-it@6.0.0
Unpacked Size
145.32 kB
Size
21.81 kB
File Count
40
NPM Version
8.7.0
Node Version
16.14.2
Published on
Jan 09, 2023
Cumulative downloads
Total Downloads
Last Day
28.2%
12,604
Compared to previous day
Last Week
-6.9%
394,161
Compared to previous week
Last Month
6.2%
1,695,335
Compared to previous month
Last Year
34.1%
16,269,810
Compared to previous year
37
Fast and consistent hashCode for any object type
1// ES2015 2import hash from 'hash-it'; 3 4// CommonJS 5const hash = require('hash-it'); 6 7// hash any standard object 8console.log(hash({ foo: 'bar' })); // 13729774857125 9 10// or a circular object 11console.log(hash(window)); // 3270731309314
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.
Any object type?
Yes, 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:
Arguments
Array
ArrayBuffer
AsyncFunction
(based on toString
)AsyncGeneratorFunction
(based on toString
)BigInt
BigInt64Array
BigUint64Array
Boolean
DataView
(based on its buffer
)Date
(based on getTime
)DocumentFragment
(based on outerHTML
of all children
)Error
(based on stack
)
TypeError
, ReferenceError
, etc.)Event
(based on all properties other than Event.timeStamp
)
MouseEvent
, KeyboardEvent
, etc.)Float32Array
Float64Array
Function
(based on toString
)GeneratorFunction
(based on toString
)Int8Array
Int16Array
Int32Array
HTMLElement
(based on outerHTML
)
HTMLAnchorElement
, HTMLDivElement
, etc.)Map
(order-agnostic)Null
Number
Object
(handles circular objects, order-agnostic)Proxy
RegExp
Set
(order-agnostic)SharedArrayBuffer
String
SVGElement
(based on outerHTML
)
SVGRectElement
, SVGPolygonElement
, etc.)Symbol
(based on toString
)Uint8Array
Uint8ClampedArray
Uint16Array
Uint32Array
Undefined
Window
Are there any exceptions?
Sadly, 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.
Promise
Generator
(the result of calling a GeneratorFunction
)
Promise
, there is no way to obtain the values contained within due to its dynamic iterable natureWeakMap
/ WeakRef
/ WeakSet
1const promise = Promise.resolve(123); 2 3console.log(hash(promise)); // 16843037491939 4console.log(hash(promise)); // 16843037491939 5console.log(hash(Promise.resolve(123))); // 4622327363876
If there is an object class or data type that is missing, please submit an issue.
While 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.
Clone the repo and dependencies via yarn
. The npm scripts available:
benchmark
=> run benchmark of various data typesbenchmark:compare
=> run benchmark of some data types comparing against other hashing modulesbuild
=> run rollup to build ESM, CJS, and UMD filesclean
=> remove files produced from build
scriptdev
=> run webpack dev server to run example app / playgroundlint
=> run ESLint against all files in the src
folderlint:fix
=> run lint
script, automatically applying fixable changesprepublishOnly
=> run typecheck
, lint
, test
, and build
start
=> alias for dev
scripttest
=> run jest test functions with NODE_ENV=test
test:coverage
=> run test
with coverage checkertest:watch
=> run test
with persistent watchertypecheck
=> run tsc
to validate internal typingsNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/5 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
32 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More