Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1 to 6.0.0-beta.2

10

CHANGELOG.md

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

- Better support for system-specific loading (ESM vs CJS vs UMD)
- Added support for primitive wrappers (e.g., `new Number('123')`)
- Added support for primitive wrappers (e.g. `new Number('123')`)
- Added support for more object classes
- `AsyncFunction`
- `AsyncGeneratorFunction`
- `BigInt64Array`
- `BigUint64Array`
- `GeneratorFunction`
- `SharedArrayBuffer`
- `WeakRef` (same limitations as those for `WeakMap` / `WeakSet`)

@@ -18,0 +26,0 @@ ## 5.0.2

112

dist/cjs/types/constants.d.ts

@@ -10,30 +10,34 @@ export declare const SEPARATOR = "|";

readonly '[object BigInt]': 5;
readonly '[object Boolean]': 6;
readonly '[object DataView]': 7;
readonly '[object Date]': 8;
readonly '[object DocumentFragment]': 9;
readonly '[object Error]': 10;
readonly '[object Event]': 11;
readonly '[object Float32Array]': 12;
readonly '[object Float64Array]': 13;
readonly '[object Function]': 14;
readonly '[object Generator]': 15;
readonly '[object GeneratorFunction]': 16;
readonly '[object Int8Array]': 17;
readonly '[object Int16Array]': 18;
readonly '[object Map]': 19;
readonly '[object Number]': 20;
readonly '[object Object]': 21;
readonly '[object Promise]': 22;
readonly '[object RegExp]': 23;
readonly '[object Set]': 24;
readonly '[object String]': 25;
readonly '[object Uint8Array]': 26;
readonly '[object Uint8ClampedArray]': 27;
readonly '[object Uint16Array]': 28;
readonly '[object Uint32Array]': 29;
readonly '[object WeakMap]': 30;
readonly '[object WeakSet]': 31;
readonly ELEMENT: 32;
readonly CUSTOM: 33;
readonly '[object BigInt64Array]': 6;
readonly '[object BigUint64Array]': 7;
readonly '[object Boolean]': 8;
readonly '[object DataView]': 9;
readonly '[object Date]': 10;
readonly '[object DocumentFragment]': 11;
readonly '[object Error]': 12;
readonly '[object Event]': 13;
readonly '[object Float32Array]': 14;
readonly '[object Float64Array]': 15;
readonly '[object Function]': 16;
readonly '[object Generator]': 17;
readonly '[object GeneratorFunction]': 18;
readonly '[object Int8Array]': 19;
readonly '[object Int16Array]': 20;
readonly '[object Map]': 21;
readonly '[object Number]': 22;
readonly '[object Object]': 23;
readonly '[object Promise]': 24;
readonly '[object RegExp]': 25;
readonly '[object Set]': 26;
readonly '[object SharedArrayBuffer]': 27;
readonly '[object String]': 28;
readonly '[object Uint8Array]': 29;
readonly '[object Uint8ClampedArray]': 30;
readonly '[object Uint16Array]': 31;
readonly '[object Uint32Array]': 32;
readonly '[object WeakMap]': 33;
readonly '[object WeakRef]': 34;
readonly '[object WeakSet]': 35;
readonly CUSTOM: 36;
readonly ELEMENT: 37;
};

@@ -50,3 +54,4 @@ export type Class = keyof typeof CLASSES;

readonly '[object WeakMap]': 3;
readonly '[object WeakSet]': 4;
readonly '[object WeakRef]': 4;
readonly '[object WeakSet]': 5;
};

@@ -65,10 +70,12 @@ export type NonEnumerableClass = keyof typeof NON_ENUMERABLE_CLASSES;

export declare const TYPED_ARRAY_CLASSES: {
readonly '[object Float32Array]': 1;
readonly '[object Float64Array]': 2;
readonly '[object Int8Array]': 3;
readonly '[object Int16Array]': 4;
readonly '[object Uint8Array]': 5;
readonly '[object Uint8ClampedArray]': 6;
readonly '[object Uint16Array]': 7;
readonly '[object Uint32Array]': 8;
readonly '[object BigInt64Array]': 1;
readonly '[object BigUint64Array]': 2;
readonly '[object Float32Array]': 3;
readonly '[object Float64Array]': 4;
readonly '[object Int8Array]': 5;
readonly '[object Int16Array]': 6;
readonly '[object Uint8Array]': 7;
readonly '[object Uint8ClampedArray]': 8;
readonly '[object Uint16Array]': 9;
readonly '[object Uint32Array]': 10;
};

@@ -80,15 +87,18 @@ export type TypedArrayClass = keyof typeof TYPED_ARRAY_CLASSES;

readonly '[object ArrayBuffer]': 3;
readonly '[object DataView]': 4;
readonly '[object Float32Array]': 5;
readonly '[object Float64Array]': 6;
readonly '[object Int8Array]': 7;
readonly '[object Int16Array]': 8;
readonly '[object Map]': 9;
readonly '[object Object]': 1;
readonly '[object Set]': 11;
readonly '[object Uint8Array]': 12;
readonly '[object Uint8ClampedArray]': 13;
readonly '[object Uint16Array]': 14;
readonly '[object Uint32Array]': 15;
readonly CUSTOM: 16;
readonly '[object BigInt64Array]': 4;
readonly '[object BigUint64Array]': 5;
readonly '[object DataView]': 6;
readonly '[object Float32Array]': 7;
readonly '[object Float64Array]': 8;
readonly '[object Int8Array]': 9;
readonly '[object Int16Array]': 10;
readonly '[object Map]': 11;
readonly '[object Object]': 12;
readonly '[object Set]': 13;
readonly '[object SharedArrayBuffer]': 14;
readonly '[object Uint8Array]': 15;
readonly '[object Uint8ClampedArray]': 16;
readonly '[object Uint16Array]': 17;
readonly '[object Uint32Array]': 18;
readonly CUSTOM: 19;
};

@@ -99,2 +109,3 @@ export type RecursiveClass = keyof typeof RECURSIVE_CLASSES;

readonly boolean: "b";
readonly empty: "e";
readonly function: "g";

@@ -105,4 +116,3 @@ readonly number: "n";

readonly symbol: "s";
readonly undefined: "u";
};
export type HashableType = keyof typeof HASHABLE_TYPES;

@@ -10,30 +10,34 @@ export declare const SEPARATOR = "|";

readonly '[object BigInt]': 5;
readonly '[object Boolean]': 6;
readonly '[object DataView]': 7;
readonly '[object Date]': 8;
readonly '[object DocumentFragment]': 9;
readonly '[object Error]': 10;
readonly '[object Event]': 11;
readonly '[object Float32Array]': 12;
readonly '[object Float64Array]': 13;
readonly '[object Function]': 14;
readonly '[object Generator]': 15;
readonly '[object GeneratorFunction]': 16;
readonly '[object Int8Array]': 17;
readonly '[object Int16Array]': 18;
readonly '[object Map]': 19;
readonly '[object Number]': 20;
readonly '[object Object]': 21;
readonly '[object Promise]': 22;
readonly '[object RegExp]': 23;
readonly '[object Set]': 24;
readonly '[object String]': 25;
readonly '[object Uint8Array]': 26;
readonly '[object Uint8ClampedArray]': 27;
readonly '[object Uint16Array]': 28;
readonly '[object Uint32Array]': 29;
readonly '[object WeakMap]': 30;
readonly '[object WeakSet]': 31;
readonly ELEMENT: 32;
readonly CUSTOM: 33;
readonly '[object BigInt64Array]': 6;
readonly '[object BigUint64Array]': 7;
readonly '[object Boolean]': 8;
readonly '[object DataView]': 9;
readonly '[object Date]': 10;
readonly '[object DocumentFragment]': 11;
readonly '[object Error]': 12;
readonly '[object Event]': 13;
readonly '[object Float32Array]': 14;
readonly '[object Float64Array]': 15;
readonly '[object Function]': 16;
readonly '[object Generator]': 17;
readonly '[object GeneratorFunction]': 18;
readonly '[object Int8Array]': 19;
readonly '[object Int16Array]': 20;
readonly '[object Map]': 21;
readonly '[object Number]': 22;
readonly '[object Object]': 23;
readonly '[object Promise]': 24;
readonly '[object RegExp]': 25;
readonly '[object Set]': 26;
readonly '[object SharedArrayBuffer]': 27;
readonly '[object String]': 28;
readonly '[object Uint8Array]': 29;
readonly '[object Uint8ClampedArray]': 30;
readonly '[object Uint16Array]': 31;
readonly '[object Uint32Array]': 32;
readonly '[object WeakMap]': 33;
readonly '[object WeakRef]': 34;
readonly '[object WeakSet]': 35;
readonly CUSTOM: 36;
readonly ELEMENT: 37;
};

@@ -50,3 +54,4 @@ export type Class = keyof typeof CLASSES;

readonly '[object WeakMap]': 3;
readonly '[object WeakSet]': 4;
readonly '[object WeakRef]': 4;
readonly '[object WeakSet]': 5;
};

@@ -65,10 +70,12 @@ export type NonEnumerableClass = keyof typeof NON_ENUMERABLE_CLASSES;

export declare const TYPED_ARRAY_CLASSES: {
readonly '[object Float32Array]': 1;
readonly '[object Float64Array]': 2;
readonly '[object Int8Array]': 3;
readonly '[object Int16Array]': 4;
readonly '[object Uint8Array]': 5;
readonly '[object Uint8ClampedArray]': 6;
readonly '[object Uint16Array]': 7;
readonly '[object Uint32Array]': 8;
readonly '[object BigInt64Array]': 1;
readonly '[object BigUint64Array]': 2;
readonly '[object Float32Array]': 3;
readonly '[object Float64Array]': 4;
readonly '[object Int8Array]': 5;
readonly '[object Int16Array]': 6;
readonly '[object Uint8Array]': 7;
readonly '[object Uint8ClampedArray]': 8;
readonly '[object Uint16Array]': 9;
readonly '[object Uint32Array]': 10;
};

@@ -80,15 +87,18 @@ export type TypedArrayClass = keyof typeof TYPED_ARRAY_CLASSES;

readonly '[object ArrayBuffer]': 3;
readonly '[object DataView]': 4;
readonly '[object Float32Array]': 5;
readonly '[object Float64Array]': 6;
readonly '[object Int8Array]': 7;
readonly '[object Int16Array]': 8;
readonly '[object Map]': 9;
readonly '[object Object]': 1;
readonly '[object Set]': 11;
readonly '[object Uint8Array]': 12;
readonly '[object Uint8ClampedArray]': 13;
readonly '[object Uint16Array]': 14;
readonly '[object Uint32Array]': 15;
readonly CUSTOM: 16;
readonly '[object BigInt64Array]': 4;
readonly '[object BigUint64Array]': 5;
readonly '[object DataView]': 6;
readonly '[object Float32Array]': 7;
readonly '[object Float64Array]': 8;
readonly '[object Int8Array]': 9;
readonly '[object Int16Array]': 10;
readonly '[object Map]': 11;
readonly '[object Object]': 12;
readonly '[object Set]': 13;
readonly '[object SharedArrayBuffer]': 14;
readonly '[object Uint8Array]': 15;
readonly '[object Uint8ClampedArray]': 16;
readonly '[object Uint16Array]': 17;
readonly '[object Uint32Array]': 18;
readonly CUSTOM: 19;
};

@@ -99,2 +109,3 @@ export type RecursiveClass = keyof typeof RECURSIVE_CLASSES;

readonly boolean: "b";
readonly empty: "e";
readonly function: "g";

@@ -105,4 +116,3 @@ readonly number: "n";

readonly symbol: "s";
readonly undefined: "u";
};
export type HashableType = keyof typeof HASHABLE_TYPES;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["hash-it"]={})}(this,(function(t){"use strict";var e="|",r=/\[object ([HTML|SVG](.*)Element)\]/,o={"[object Arguments]":0,"[object Array]":1,"[object ArrayBuffer]":2,"[object AsyncFunction]":3,"[object AsyncGeneratorFunction]":4,"[object BigInt]":5,"[object Boolean]":6,"[object DataView]":7,"[object Date]":8,"[object DocumentFragment]":9,"[object Error]":10,"[object Event]":11,"[object Float32Array]":12,"[object Float64Array]":13,"[object Function]":14,"[object Generator]":15,"[object GeneratorFunction]":16,"[object Int8Array]":17,"[object Int16Array]":18,"[object Map]":19,"[object Number]":20,"[object Object]":21,"[object Promise]":22,"[object RegExp]":23,"[object Set]":24,"[object String]":25,"[object Uint8Array]":26,"[object Uint8ClampedArray]":27,"[object Uint16Array]":28,"[object Uint32Array]":29,"[object WeakMap]":30,"[object WeakSet]":31,ELEMENT:32,CUSTOM:33},n={"[object Arguments]":1,"[object Array]":2},c={"[object Generator]":1,"[object Promise]":2,"[object WeakMap]":3,"[object WeakSet]":4},a={"[object AsyncFunction]":1,"[object AsyncGeneratorFunction]":2,"[object Boolean]":3,"[object Function]":4,"[object GeneratorFunction]":5,"[object Number]":6,"[object String]":7},b={"[object Float32Array]":1,"[object Float64Array]":2,"[object Int8Array]":3,"[object Int16Array]":4,"[object Uint8Array]":5,"[object Uint8ClampedArray]":6,"[object Uint16Array]":7,"[object Uint32Array]":8},i={"[object Arguments]":1,"[object Array]":2,"[object ArrayBuffer]":3,"[object DataView]":4,"[object Float32Array]":5,"[object Float64Array]":6,"[object Int8Array]":7,"[object Int16Array]":8,"[object Map]":9,"[object Object]":1,"[object Set]":11,"[object Uint8Array]":12,"[object Uint8ClampedArray]":13,"[object Uint16Array]":14,"[object Uint32Array]":15,CUSTOM:16},j={bigint:"i",boolean:"b",function:"g",number:"n",object:"o",string:"s",symbol:"s",undefined:"u"};function u(t,e){return t[0]>e[0]}function f(t,e){return t>e}function y(t,e){for(var r,o,n=0;n<t.length;++n){for(o=t[n],r=n-1;~r&&e(t[r],o);--r)t[r+1]=t[r];t[r+1]=o}return t}function A(t,r){return j.object+e+o[t]+e+r}var l=new WeakMap,s=0;function g(t,e){var r=l.get(t);if(r)return r;var o=A(e,"NOT_ENUMERABLE|"+s++);return l.set(t,o),o}var p=Object.prototype.toString;function d(t,o,n){if(i[o])return m(o,t,n);if("[object Date]"===o)return A(o,t.getTime());if("[object RegExp]"===o)return A(o,t.toString());if("[object Event]"===o)return A(o,[t.bubbles,t.cancelBubble,t.cancelable,t.composed,t.currentTarget,t.defaultPrevented,t.eventPhase,t.isTrusted,t.returnValue,t.target,t.type].join());if("[object Error]"===o)return A(o,t.message+e+t.stack);if("[object DocumentFragment]"===o)return A(o,function(t){var e=t.children,r=e.length,o=new Array(r);for(;--r>=0;)o[r]=e[r].outerHTML;return o.join()}(t));var b=o.match(r);return b?A("ELEMENT",b[1]+e+t.outerHTML):c[o]?g(t,o):a[o]?A(o,t.toString()):m("CUSTOM",t,n)}function m(t,e,r){var o=r.cache.get(e);return o?A(t,"RECURSIVE~"+o):(r.cache.set(e,++r.id),"[object Object]"===t?e[Symbol.iterator]?g(e,t):A(t,U(e,r)):n[t]?A(t,function(t,e){var r=t.length,o=new Array(r);for(;--r>=0;)o[r]=E(t[r],e);return o.join()}(e,r)):"[object Map]"===t?A(t,function(t,e){var r=new Array(t.size),o=0;t.forEach((function(t,n){r[o++]=[E(n,e),E(t,e)]})),y(r,u);for(;--o>=0;)r[o]="["+r[o][0]+","+r[o][1]+"]";return"["+r.join()+"]"}(e,r)):"[object Set]"===t?A(t,function(t,e){var r=new Array(t.size),o=0;return t.forEach((function(t){r[o++]=E(t,e)})),"["+y(r,f).join()+"]"}(e,r)):b[t]?A(t,e.join()):"[object ArrayBuffer]"===t?A(t,v(e)):"[object DataView]"===t?A(t,v(e.buffer)):c[t]?g(e,t):A("CUSTOM",U(e,r)))}var v="undefined"!=typeof Buffer&&"function"==typeof Buffer.from?function(t){return Buffer.from(t).toString("utf8")}:"function"==typeof Uint16Array?function(t){return String.fromCharCode.apply(null,new Uint16Array(t))}:function(){return"UNSUPPORTED"};function U(t,e){for(var r=y(Object.getOwnPropertyNames(t),f),o=r.length,n=new Array(o),c=o;--c>=0;)n[c]=r[c]+":"+E(t[r[c]],e);return"{"+n.join()+"}"}function E(t,e){var r=typeof t;return"object"===r&&t?d(t,p.call(t),e||{cache:new WeakMap,id:1}):j[r]+("function"===r||"symbol"===r?t.toString():t)}t.default=function(t){return function(t){for(var e,r=t.length,o=5381,n=52711;r--;)o=33*o^(e=t.charCodeAt(r)),n=33*n^e;return 4096*(o>>>0)+(n>>>0)}(E(t,void 0))},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["hash-it"]={})}(this,(function(e){"use strict";var t="|",r=/\[object ([HTML|SVG](.*)Element)\]/,o={"[object Arguments]":0,"[object Array]":1,"[object ArrayBuffer]":2,"[object AsyncFunction]":3,"[object AsyncGeneratorFunction]":4,"[object BigInt]":5,"[object BigInt64Array]":6,"[object BigUint64Array]":7,"[object Boolean]":8,"[object DataView]":9,"[object Date]":10,"[object DocumentFragment]":11,"[object Error]":12,"[object Event]":13,"[object Float32Array]":14,"[object Float64Array]":15,"[object Function]":16,"[object Generator]":17,"[object GeneratorFunction]":18,"[object Int8Array]":19,"[object Int16Array]":20,"[object Map]":21,"[object Number]":22,"[object Object]":23,"[object Promise]":24,"[object RegExp]":25,"[object Set]":26,"[object SharedArrayBuffer]":27,"[object String]":28,"[object Uint8Array]":29,"[object Uint8ClampedArray]":30,"[object Uint16Array]":31,"[object Uint32Array]":32,"[object WeakMap]":33,"[object WeakRef]":34,"[object WeakSet]":35,CUSTOM:36,ELEMENT:37},n={"[object Arguments]":1,"[object Array]":2},c={"[object Generator]":1,"[object Promise]":2,"[object WeakMap]":3,"[object WeakRef]":4,"[object WeakSet]":5},a={"[object AsyncFunction]":1,"[object AsyncGeneratorFunction]":2,"[object Boolean]":3,"[object Function]":4,"[object GeneratorFunction]":5,"[object Number]":6,"[object String]":7},b={"[object BigInt64Array]":1,"[object BigUint64Array]":2,"[object Float32Array]":3,"[object Float64Array]":4,"[object Int8Array]":5,"[object Int16Array]":6,"[object Uint8Array]":7,"[object Uint8ClampedArray]":8,"[object Uint16Array]":9,"[object Uint32Array]":10},i={"[object Arguments]":1,"[object Array]":2,"[object ArrayBuffer]":3,"[object BigInt64Array]":4,"[object BigUint64Array]":5,"[object DataView]":6,"[object Float32Array]":7,"[object Float64Array]":8,"[object Int8Array]":9,"[object Int16Array]":10,"[object Map]":11,"[object Object]":12,"[object Set]":13,"[object SharedArrayBuffer]":14,"[object Uint8Array]":15,"[object Uint8ClampedArray]":16,"[object Uint16Array]":17,"[object Uint32Array]":18,CUSTOM:19},j={bigint:"i",boolean:"b",empty:"e",function:"g",number:"n",object:"o",string:"s",symbol:"s"};function u(e,t){return e[0]>t[0]}function f(e,t){return e>t}function y(e,t){for(var r,o,n=0;n<e.length;++n){for(o=e[n],r=n-1;~r&&t(e[r],o);--r)e[r+1]=e[r];e[r+1]=o}return e}function A(e,r){return j.object+t+o[e]+t+r}var l=new WeakMap,g=0;function s(e,t){var r=l.get(e);if(r)return r;var o=A(t,"NOT_ENUMERABLE|"+g++);return l.set(e,o),o}var p=Object.prototype.toString;function d(e,o,n){if(i[o])return m(o,e,n);if("[object Date]"===o)return A(o,e.getTime());if("[object RegExp]"===o)return A(o,e.toString());if("[object Event]"===o)return A(o,[e.bubbles,e.cancelBubble,e.cancelable,e.composed,e.currentTarget,e.defaultPrevented,e.eventPhase,e.isTrusted,e.returnValue,e.target,e.type].join());if("[object Error]"===o)return A(o,e.message+t+e.stack);if("[object DocumentFragment]"===o)return A(o,function(e){var t=e.children,r=t.length,o=new Array(r);for(;--r>=0;)o[r]=t[r].outerHTML;return o.join()}(e));var b=o.match(r);return b?A("ELEMENT",b[1]+t+e.outerHTML):c[o]?s(e,o):a[o]?A(o,e.toString()):m("CUSTOM",e,n)}function m(e,t,r){var o=r.cache.get(t);return o?A(e,"RECURSIVE~"+o):(r.cache.set(t,++r.id),"[object Object]"===e?t[Symbol.iterator]?s(t,e):A(e,S(t,r)):n[e]?A(e,function(e,t){var r=e.length,o=new Array(r);for(;--r>=0;)o[r]=h(e[r],t);return o.join()}(t,r)):"[object Map]"===e?A(e,function(e,t){var r=new Array(e.size),o=0;e.forEach((function(e,n){r[o++]=[h(n,t),h(e,t)]})),y(r,u);for(;--o>=0;)r[o]="["+r[o][0]+","+r[o][1]+"]";return"["+r.join()+"]"}(t,r)):"[object Set]"===e?A(e,function(e,t){var r=new Array(e.size),o=0;return e.forEach((function(e){r[o++]=h(e,t)})),"["+y(r,f).join()+"]"}(t,r)):b[e]?A(e,t.join()):"[object ArrayBuffer]"===e?A(e,U(t)):"[object DataView]"===e?A(e,U(t.buffer)):c[e]?s(t,e):A("CUSTOM",S(t,r)))}var U="undefined"!=typeof Buffer&&"function"==typeof Buffer.from?function(e){return Buffer.from(e).toString("utf8")}:"function"==typeof Uint16Array?function(e){return String.fromCharCode.apply(null,new Uint16Array(e))}:function(){return"UNSUPPORTED"};function S(e,t){for(var r=y(Object.getOwnPropertyNames(e),f),o=r.length,n=new Array(o),c=o;--c>=0;)n[c]=r[c]+":"+h(e[r[c]],t);return"{"+n.join()+"}"}function h(e,t){var r=typeof e;return null==e||"undefined"===r?j.empty+e:"object"===r?d(e,p.call(e),t||{cache:new WeakMap,id:1}):"function"===r||"symbol"===r?j[r]+e.toString():"boolean"===r?j.boolean+ +e:j[r]+e}e.default=function(e){return function(e){for(var t,r=e.length,o=5381,n=52711;r--;)o=33*o^(t=e.charCodeAt(r)),n=33*n^t;return 4096*(o>>>0)+(n>>>0)}(h(e,void 0))},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -10,30 +10,34 @@ export declare const SEPARATOR = "|";

readonly '[object BigInt]': 5;
readonly '[object Boolean]': 6;
readonly '[object DataView]': 7;
readonly '[object Date]': 8;
readonly '[object DocumentFragment]': 9;
readonly '[object Error]': 10;
readonly '[object Event]': 11;
readonly '[object Float32Array]': 12;
readonly '[object Float64Array]': 13;
readonly '[object Function]': 14;
readonly '[object Generator]': 15;
readonly '[object GeneratorFunction]': 16;
readonly '[object Int8Array]': 17;
readonly '[object Int16Array]': 18;
readonly '[object Map]': 19;
readonly '[object Number]': 20;
readonly '[object Object]': 21;
readonly '[object Promise]': 22;
readonly '[object RegExp]': 23;
readonly '[object Set]': 24;
readonly '[object String]': 25;
readonly '[object Uint8Array]': 26;
readonly '[object Uint8ClampedArray]': 27;
readonly '[object Uint16Array]': 28;
readonly '[object Uint32Array]': 29;
readonly '[object WeakMap]': 30;
readonly '[object WeakSet]': 31;
readonly ELEMENT: 32;
readonly CUSTOM: 33;
readonly '[object BigInt64Array]': 6;
readonly '[object BigUint64Array]': 7;
readonly '[object Boolean]': 8;
readonly '[object DataView]': 9;
readonly '[object Date]': 10;
readonly '[object DocumentFragment]': 11;
readonly '[object Error]': 12;
readonly '[object Event]': 13;
readonly '[object Float32Array]': 14;
readonly '[object Float64Array]': 15;
readonly '[object Function]': 16;
readonly '[object Generator]': 17;
readonly '[object GeneratorFunction]': 18;
readonly '[object Int8Array]': 19;
readonly '[object Int16Array]': 20;
readonly '[object Map]': 21;
readonly '[object Number]': 22;
readonly '[object Object]': 23;
readonly '[object Promise]': 24;
readonly '[object RegExp]': 25;
readonly '[object Set]': 26;
readonly '[object SharedArrayBuffer]': 27;
readonly '[object String]': 28;
readonly '[object Uint8Array]': 29;
readonly '[object Uint8ClampedArray]': 30;
readonly '[object Uint16Array]': 31;
readonly '[object Uint32Array]': 32;
readonly '[object WeakMap]': 33;
readonly '[object WeakRef]': 34;
readonly '[object WeakSet]': 35;
readonly CUSTOM: 36;
readonly ELEMENT: 37;
};

@@ -50,3 +54,4 @@ export type Class = keyof typeof CLASSES;

readonly '[object WeakMap]': 3;
readonly '[object WeakSet]': 4;
readonly '[object WeakRef]': 4;
readonly '[object WeakSet]': 5;
};

@@ -65,10 +70,12 @@ export type NonEnumerableClass = keyof typeof NON_ENUMERABLE_CLASSES;

export declare const TYPED_ARRAY_CLASSES: {
readonly '[object Float32Array]': 1;
readonly '[object Float64Array]': 2;
readonly '[object Int8Array]': 3;
readonly '[object Int16Array]': 4;
readonly '[object Uint8Array]': 5;
readonly '[object Uint8ClampedArray]': 6;
readonly '[object Uint16Array]': 7;
readonly '[object Uint32Array]': 8;
readonly '[object BigInt64Array]': 1;
readonly '[object BigUint64Array]': 2;
readonly '[object Float32Array]': 3;
readonly '[object Float64Array]': 4;
readonly '[object Int8Array]': 5;
readonly '[object Int16Array]': 6;
readonly '[object Uint8Array]': 7;
readonly '[object Uint8ClampedArray]': 8;
readonly '[object Uint16Array]': 9;
readonly '[object Uint32Array]': 10;
};

@@ -80,15 +87,18 @@ export type TypedArrayClass = keyof typeof TYPED_ARRAY_CLASSES;

readonly '[object ArrayBuffer]': 3;
readonly '[object DataView]': 4;
readonly '[object Float32Array]': 5;
readonly '[object Float64Array]': 6;
readonly '[object Int8Array]': 7;
readonly '[object Int16Array]': 8;
readonly '[object Map]': 9;
readonly '[object Object]': 1;
readonly '[object Set]': 11;
readonly '[object Uint8Array]': 12;
readonly '[object Uint8ClampedArray]': 13;
readonly '[object Uint16Array]': 14;
readonly '[object Uint32Array]': 15;
readonly CUSTOM: 16;
readonly '[object BigInt64Array]': 4;
readonly '[object BigUint64Array]': 5;
readonly '[object DataView]': 6;
readonly '[object Float32Array]': 7;
readonly '[object Float64Array]': 8;
readonly '[object Int8Array]': 9;
readonly '[object Int16Array]': 10;
readonly '[object Map]': 11;
readonly '[object Object]': 12;
readonly '[object Set]': 13;
readonly '[object SharedArrayBuffer]': 14;
readonly '[object Uint8Array]': 15;
readonly '[object Uint8ClampedArray]': 16;
readonly '[object Uint16Array]': 17;
readonly '[object Uint32Array]': 18;
readonly CUSTOM: 19;
};

@@ -99,2 +109,3 @@ export type RecursiveClass = keyof typeof RECURSIVE_CLASSES;

readonly boolean: "b";
readonly empty: "e";
readonly function: "g";

@@ -105,4 +116,3 @@ readonly number: "n";

readonly symbol: "s";
readonly undefined: "u";
};
export type HashableType = keyof typeof HASHABLE_TYPES;

@@ -34,30 +34,34 @@ (function (global, factory) {

'[object BigInt]': 5,
'[object Boolean]': 6,
'[object DataView]': 7,
'[object Date]': 8,
'[object DocumentFragment]': 9,
'[object Error]': 10,
'[object Event]': 11,
'[object Float32Array]': 12,
'[object Float64Array]': 13,
'[object Function]': 14,
'[object Generator]': 15,
'[object GeneratorFunction]': 16,
'[object Int8Array]': 17,
'[object Int16Array]': 18,
'[object Map]': 19,
'[object Number]': 20,
'[object Object]': 21,
'[object Promise]': 22,
'[object RegExp]': 23,
'[object Set]': 24,
'[object String]': 25,
'[object Uint8Array]': 26,
'[object Uint8ClampedArray]': 27,
'[object Uint16Array]': 28,
'[object Uint32Array]': 29,
'[object WeakMap]': 30,
'[object WeakSet]': 31,
ELEMENT: 32,
CUSTOM: 33,
'[object BigInt64Array]': 6,
'[object BigUint64Array]': 7,
'[object Boolean]': 8,
'[object DataView]': 9,
'[object Date]': 10,
'[object DocumentFragment]': 11,
'[object Error]': 12,
'[object Event]': 13,
'[object Float32Array]': 14,
'[object Float64Array]': 15,
'[object Function]': 16,
'[object Generator]': 17,
'[object GeneratorFunction]': 18,
'[object Int8Array]': 19,
'[object Int16Array]': 20,
'[object Map]': 21,
'[object Number]': 22,
'[object Object]': 23,
'[object Promise]': 24,
'[object RegExp]': 25,
'[object Set]': 26,
'[object SharedArrayBuffer]': 27,
'[object String]': 28,
'[object Uint8Array]': 29,
'[object Uint8ClampedArray]': 30,
'[object Uint16Array]': 31,
'[object Uint32Array]': 32,
'[object WeakMap]': 33,
'[object WeakRef]': 34,
'[object WeakSet]': 35,
CUSTOM: 36,
ELEMENT: 37,
};

@@ -72,3 +76,4 @@ var ARRAY_LIKE_CLASSES = {

'[object WeakMap]': 3,
'[object WeakSet]': 4,
'[object WeakRef]': 4,
'[object WeakSet]': 5,
};

@@ -85,10 +90,12 @@ var PRIMITIVE_WRAPPER_CLASSES = {

var TYPED_ARRAY_CLASSES = {
'[object Float32Array]': 1,
'[object Float64Array]': 2,
'[object Int8Array]': 3,
'[object Int16Array]': 4,
'[object Uint8Array]': 5,
'[object Uint8ClampedArray]': 6,
'[object Uint16Array]': 7,
'[object Uint32Array]': 8,
'[object BigInt64Array]': 1,
'[object BigUint64Array]': 2,
'[object Float32Array]': 3,
'[object Float64Array]': 4,
'[object Int8Array]': 5,
'[object Int16Array]': 6,
'[object Uint8Array]': 7,
'[object Uint8ClampedArray]': 8,
'[object Uint16Array]': 9,
'[object Uint32Array]': 10,
};

@@ -99,15 +106,18 @@ var RECURSIVE_CLASSES = {

'[object ArrayBuffer]': 3,
'[object DataView]': 4,
'[object Float32Array]': 5,
'[object Float64Array]': 6,
'[object Int8Array]': 7,
'[object Int16Array]': 8,
'[object Map]': 9,
'[object Object]': 1,
'[object Set]': 11,
'[object Uint8Array]': 12,
'[object Uint8ClampedArray]': 13,
'[object Uint16Array]': 14,
'[object Uint32Array]': 15,
CUSTOM: 16,
'[object BigInt64Array]': 4,
'[object BigUint64Array]': 5,
'[object DataView]': 6,
'[object Float32Array]': 7,
'[object Float64Array]': 8,
'[object Int8Array]': 9,
'[object Int16Array]': 10,
'[object Map]': 11,
'[object Object]': 12,
'[object Set]': 13,
'[object SharedArrayBuffer]': 14,
'[object Uint8Array]': 15,
'[object Uint8ClampedArray]': 16,
'[object Uint16Array]': 17,
'[object Uint32Array]': 18,
CUSTOM: 19,
};

@@ -117,2 +127,3 @@ var HASHABLE_TYPES = {

boolean: 'b',
empty: 'e',
function: 'g',

@@ -123,3 +134,2 @@ number: 'n',

symbol: 's',
undefined: 'u',
};

@@ -305,7 +315,15 @@

var type = typeof value;
if (type === 'object' && value) {
if (value == null || type === 'undefined') {
return HASHABLE_TYPES.empty + value;
}
if (type === 'object') {
return stringifyComplexType(value, toString.call(value), state || { cache: new WeakMap(), id: 1 });
}
return (HASHABLE_TYPES[type] +
(type === 'function' || type === 'symbol' ? value.toString() : value));
if (type === 'function' || type === 'symbol') {
return HASHABLE_TYPES[type] + value.toString();
}
if (type === 'boolean') {
return HASHABLE_TYPES.boolean + +value;
}
return HASHABLE_TYPES[type] + value;
}

@@ -312,0 +330,0 @@

@@ -10,30 +10,34 @@ export declare const SEPARATOR = "|";

readonly '[object BigInt]': 5;
readonly '[object Boolean]': 6;
readonly '[object DataView]': 7;
readonly '[object Date]': 8;
readonly '[object DocumentFragment]': 9;
readonly '[object Error]': 10;
readonly '[object Event]': 11;
readonly '[object Float32Array]': 12;
readonly '[object Float64Array]': 13;
readonly '[object Function]': 14;
readonly '[object Generator]': 15;
readonly '[object GeneratorFunction]': 16;
readonly '[object Int8Array]': 17;
readonly '[object Int16Array]': 18;
readonly '[object Map]': 19;
readonly '[object Number]': 20;
readonly '[object Object]': 21;
readonly '[object Promise]': 22;
readonly '[object RegExp]': 23;
readonly '[object Set]': 24;
readonly '[object String]': 25;
readonly '[object Uint8Array]': 26;
readonly '[object Uint8ClampedArray]': 27;
readonly '[object Uint16Array]': 28;
readonly '[object Uint32Array]': 29;
readonly '[object WeakMap]': 30;
readonly '[object WeakSet]': 31;
readonly ELEMENT: 32;
readonly CUSTOM: 33;
readonly '[object BigInt64Array]': 6;
readonly '[object BigUint64Array]': 7;
readonly '[object Boolean]': 8;
readonly '[object DataView]': 9;
readonly '[object Date]': 10;
readonly '[object DocumentFragment]': 11;
readonly '[object Error]': 12;
readonly '[object Event]': 13;
readonly '[object Float32Array]': 14;
readonly '[object Float64Array]': 15;
readonly '[object Function]': 16;
readonly '[object Generator]': 17;
readonly '[object GeneratorFunction]': 18;
readonly '[object Int8Array]': 19;
readonly '[object Int16Array]': 20;
readonly '[object Map]': 21;
readonly '[object Number]': 22;
readonly '[object Object]': 23;
readonly '[object Promise]': 24;
readonly '[object RegExp]': 25;
readonly '[object Set]': 26;
readonly '[object SharedArrayBuffer]': 27;
readonly '[object String]': 28;
readonly '[object Uint8Array]': 29;
readonly '[object Uint8ClampedArray]': 30;
readonly '[object Uint16Array]': 31;
readonly '[object Uint32Array]': 32;
readonly '[object WeakMap]': 33;
readonly '[object WeakRef]': 34;
readonly '[object WeakSet]': 35;
readonly CUSTOM: 36;
readonly ELEMENT: 37;
};

@@ -50,3 +54,4 @@ export type Class = keyof typeof CLASSES;

readonly '[object WeakMap]': 3;
readonly '[object WeakSet]': 4;
readonly '[object WeakRef]': 4;
readonly '[object WeakSet]': 5;
};

@@ -65,10 +70,12 @@ export type NonEnumerableClass = keyof typeof NON_ENUMERABLE_CLASSES;

export declare const TYPED_ARRAY_CLASSES: {
readonly '[object Float32Array]': 1;
readonly '[object Float64Array]': 2;
readonly '[object Int8Array]': 3;
readonly '[object Int16Array]': 4;
readonly '[object Uint8Array]': 5;
readonly '[object Uint8ClampedArray]': 6;
readonly '[object Uint16Array]': 7;
readonly '[object Uint32Array]': 8;
readonly '[object BigInt64Array]': 1;
readonly '[object BigUint64Array]': 2;
readonly '[object Float32Array]': 3;
readonly '[object Float64Array]': 4;
readonly '[object Int8Array]': 5;
readonly '[object Int16Array]': 6;
readonly '[object Uint8Array]': 7;
readonly '[object Uint8ClampedArray]': 8;
readonly '[object Uint16Array]': 9;
readonly '[object Uint32Array]': 10;
};

@@ -80,15 +87,18 @@ export type TypedArrayClass = keyof typeof TYPED_ARRAY_CLASSES;

readonly '[object ArrayBuffer]': 3;
readonly '[object DataView]': 4;
readonly '[object Float32Array]': 5;
readonly '[object Float64Array]': 6;
readonly '[object Int8Array]': 7;
readonly '[object Int16Array]': 8;
readonly '[object Map]': 9;
readonly '[object Object]': 1;
readonly '[object Set]': 11;
readonly '[object Uint8Array]': 12;
readonly '[object Uint8ClampedArray]': 13;
readonly '[object Uint16Array]': 14;
readonly '[object Uint32Array]': 15;
readonly CUSTOM: 16;
readonly '[object BigInt64Array]': 4;
readonly '[object BigUint64Array]': 5;
readonly '[object DataView]': 6;
readonly '[object Float32Array]': 7;
readonly '[object Float64Array]': 8;
readonly '[object Int8Array]': 9;
readonly '[object Int16Array]': 10;
readonly '[object Map]': 11;
readonly '[object Object]': 12;
readonly '[object Set]': 13;
readonly '[object SharedArrayBuffer]': 14;
readonly '[object Uint8Array]': 15;
readonly '[object Uint8ClampedArray]': 16;
readonly '[object Uint16Array]': 17;
readonly '[object Uint32Array]': 18;
readonly CUSTOM: 19;
};

@@ -99,2 +109,3 @@ export type RecursiveClass = keyof typeof RECURSIVE_CLASSES;

readonly boolean: "b";
readonly empty: "e";
readonly function: "g";

@@ -105,4 +116,3 @@ readonly number: "n";

readonly symbol: "s";
readonly undefined: "u";
};
export type HashableType = keyof typeof HASHABLE_TYPES;

@@ -48,2 +48,3 @@ {

"ts-jest": "^29.0.3",
"ts-loader": "^9.4.2",
"tslib": "^2.4.1",

@@ -112,3 +113,3 @@ "typescript": "^4.9.4",

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

@@ -11,7 +11,2 @@ # hash-it

- [Overview](#overview)
- [Equality methods](#equality-methods)
- [hash.is](#hashis)
- [hash.is.all](#hashisall)
- [hash.is.any](#hashisany)
- [hash.is.not](#hashisnot)
- [Note](#note)

@@ -55,9 +50,19 @@ - [Support](#support)

- Like `Promise`, there is no way to obtain the values contained within due to its dynamic iterable nature
- `WeakMap` / `WeakSet`
- `WeakMap` / `WeakRef` / `WeakSet`
- The spec explicitly forbids iteration over them, so the unique values cannot be discovered
In 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!
For each of these object types, the object will have a unique hash based on the object reference itself:
Here is the list of object classes that produce unique hashes:
```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`

@@ -105,69 +110,2 @@ - `Array`

## Equality methods
### hash.is
`hash.is(value1: any, value2: any): boolean`
Compares the two objects to determine equality.
```javascript
console.log(hash.is(null, 123)); // false
console.log(hash.is(null, null)); // true
```
### hash.is.all
`hash.is.all(value1: any, value2: any[, value3: any[, ...valueN]]): boolean`
Compares the first object to all other objects passed to determine if all are equal based on hashCode
```javascript
const foo = {
foo: 'bar',
};
const alsoFoo = {
foo: 'bar',
};
const stillFoo = {
foo: 'bar',
};
console.log(hash.is.all(foo, alsoFoo)); // true
console.log(hash.is.all(foo, alsoFoo, stillFoo)); // true
```
### hash.is.any
`hash.is.any(value1: any, value2: any[, value3: any[, ...valueN]]): boolean`
Compares the first object to all other objects passed to determine if any are equal based on hashCode
```javascript
const foo = {
foo: 'bar',
};
const alsoFoo = {
foo: 'bar',
};
const nopeBar = {
bar: 'baz',
};
console.log(hash.is.any(foo, alsoFoo)); // true
console.log(hash.is.any(foo, nopeBar)); // false
console.log(hash.is.any(foo, alsoFoo, nopeBar)); // true
```
### hash.is.not
`hash.is.not(value1: any, value2: any): boolean`
Compares the two objects to determine non-equality.
```javascript
console.log(hash.is.not(null, 123)); // true
console.log(hash.is.not(null, null)); // false
```
## Note

@@ -174,0 +112,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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