New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hash-it

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-it - npm Package Compare versions

Comparing version 6.0.0-beta.2 to 6.0.0

18

package.json

@@ -21,11 +21,11 @@ {

"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.2.1",
"@rollup/plugin-typescript": "^10.0.1",
"@types/jest": "^29.2.4",
"@rollup/plugin-terser": "^0.3.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/jest": "^29.2.5",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"benchmark": "^2.1.4",
"eslint": "^8.30.0",
"eslint": "^8.31.0",
"eslint-friendly-formatter": "^4.0.1",

@@ -35,3 +35,3 @@ "eslint-webpack-plugin": "^3.2.0",

"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.2",
"husky": "^8.0.3",
"jest": "^29.3.1",

@@ -48,3 +48,3 @@ "jest-environment-jsdom": "^29.3.1",

"rimraf": "^3.0.2",
"rollup": "^3.9.0",
"rollup": "^3.9.1",
"ts-jest": "^29.0.3",

@@ -115,3 +115,3 @@ "ts-loader": "^9.4.2",

"types": "./index.d.ts",
"version": "6.0.0-beta.2"
"version": "6.0.0"
}

@@ -11,3 +11,3 @@ # hash-it

- [Overview](#overview)
- [Note](#note)
- [Hash consistency](#hash-consistency)
- [Support](#support)

@@ -40,29 +40,4 @@ - [Browsers](#browsers)

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.
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:
_With no exceptions?_
Well ... sadly, no, there are a few exceptions.
- `Promise`
- There is no way to obtain the values contained within due to its asynchronous nature
- `Generator` (the result of calling a `GeneratorFunction`)
- Like `Promise`, there is no way to obtain the values contained within due to its dynamic iterable nature
- `WeakMap` / `WeakRef` / `WeakSet`
- The spec explicitly forbids iteration over them, so the unique values cannot be discovered
For each of these object types, the object will have a unique hash based on the object reference itself:
```ts
const promise = Promise.resolve(123);
console.log(hash(promise)); // 16843037491939
console.log(hash(promise)); // 16843037491939
console.log(hash(Promise.resolve(123))); // 4622327363876
```
Notice even if the internal values of the object are the same, the hash is different. This is because the values of the above object types cannot be introspected.
Here is the list of object classes that produce consistent, unique hashes based on their value:
- `Arguments`

@@ -72,3 +47,6 @@ - `Array`

- `AsyncFunction` (based on `toString`)
- `AsyncGeneratorFunction` (based on `toString`)
- `BigInt`
- `BigInt64Array`
- `BigUint64Array`
- `Boolean`

@@ -98,2 +76,3 @@ - `DataView` (based on its `buffer`)

- `Set` (order-agnostic)
- `SharedArrayBuffer`
- `String`

@@ -110,5 +89,24 @@ - `SVGElement` (based on `outerHTML`)

_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`
- There is no way to obtain the values contained within due to its asynchronous nature
- `Generator` (the result of calling a `GeneratorFunction`)
- Like `Promise`, there is no way to obtain the values contained within due to its dynamic iterable nature
- `WeakMap` / `WeakRef` / `WeakSet`
- The spec explicitly forbids iteration over them, so the unique values cannot be discovered
```ts
const promise = Promise.resolve(123);
console.log(hash(promise)); // 16843037491939
console.log(hash(promise)); // 16843037491939
console.log(hash(Promise.resolve(123))); // 4622327363876
```
If there is an object class or data type that is missing, please submit an issue.
## Note
## Hash consistency

@@ -115,0 +113,0 @@ 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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc