@alwatr/cyrb53 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/main.cjs +2 -52
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +2 -28
- package/dist/main.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/cyrb53@1.0.0...@alwatr/cyrb53@1.0.1) (2025-09-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @alwatr/cyrb53
|
|
9
|
+
|
|
6
10
|
## 1.0.0 (2025-09-14)
|
|
7
11
|
|
|
8
12
|
### ✨ Features
|
package/dist/main.cjs
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
/* @alwatr/cyrb53 v1.0.
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/main.ts
|
|
22
|
-
var main_exports = {};
|
|
23
|
-
__export(main_exports, {
|
|
24
|
-
cyrb53: () => cyrb53
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(main_exports);
|
|
27
|
-
var H1_SEED = 3735928559;
|
|
28
|
-
var H2_SEED = 1103547991;
|
|
29
|
-
var M_K1 = 2654435761;
|
|
30
|
-
var M_K2 = 1597334677;
|
|
31
|
-
var F_K1 = 2246822507;
|
|
32
|
-
var F_K2 = 3266489909;
|
|
33
|
-
var P_K1 = 4294967296;
|
|
34
|
-
var P_K2 = 2097151;
|
|
35
|
-
function cyrb53(str, seed = 0) {
|
|
36
|
-
let h1 = H1_SEED ^ seed;
|
|
37
|
-
let h2 = H2_SEED ^ seed;
|
|
38
|
-
for (let i = 0, ch; i < str.length; i++) {
|
|
39
|
-
ch = str.charCodeAt(i);
|
|
40
|
-
h1 = Math.imul(h1 ^ ch, M_K1);
|
|
41
|
-
h2 = Math.imul(h2 ^ ch, M_K2);
|
|
42
|
-
}
|
|
43
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, F_K1);
|
|
44
|
-
h1 ^= Math.imul(h2 ^ h2 >>> 13, F_K2);
|
|
45
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, F_K1);
|
|
46
|
-
h2 ^= Math.imul(h1 ^ h1 >>> 13, F_K2);
|
|
47
|
-
return P_K1 * (P_K2 & h2) + (h1 >>> 0);
|
|
48
|
-
}
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
cyrb53
|
|
52
|
-
});
|
|
1
|
+
/* @alwatr/cyrb53 v1.0.1 */
|
|
2
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{cyrb53:()=>cyrb53});module.exports=__toCommonJS(main_exports);var H1_SEED=3735928559;var H2_SEED=1103547991;var M_K1=2654435761;var M_K2=1597334677;var F_K1=2246822507;var F_K2=3266489909;var P_K1=4294967296;var P_K2=2097151;function cyrb53(str,seed=0){let h1=H1_SEED^seed;let h2=H2_SEED^seed;for(let i=0,ch;i<str.length;i++){ch=str.charCodeAt(i);h1=Math.imul(h1^ch,M_K1);h2=Math.imul(h2^ch,M_K2)}h1=Math.imul(h1^h1>>>16,F_K1);h1^=Math.imul(h2^h2>>>13,F_K2);h2=Math.imul(h2^h2>>>16,F_K1);h2^=Math.imul(h1^h1>>>13,F_K2);return P_K1*(P_K2&h2)+(h1>>>0)}0&&(module.exports={cyrb53});
|
|
53
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["const H1_SEED = 0xdeadbeef;\nconst H2_SEED = 0x41c6ce57;\nconst M_K1 = 2654435761;\nconst M_K2 = 1597334677;\nconst F_K1 = 2246822507;\nconst F_K2 = 3266489909;\nconst P_K1 = 4294967296; // 2^32\nconst P_K2 = 2097151; // 2^21 - 1\n\n/**\n * cyrb53: A modern, high-quality, and fast 53-bit string hash function.\n *\n * Excellent collision resistance due to its large output space.\n * The best choice for new general-purpose hashing needs in JS/TS.\n *\n * @param str The input string.\n * @param seed An optional seed value.\n * @returns A 53-bit hash number.\n *\n * @example\n * ```ts\n * const hash = cyrb53('some string');\n * ```\n */\nexport function cyrb53(str: string, seed = 0): number {\n let h1 = H1_SEED ^ seed;\n let h2 = H2_SEED ^ seed;\n\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, M_K1);\n h2 = Math.imul(h2 ^ ch, M_K2);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), F_K1);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), F_K2);\n h2 = Math.imul(h2 ^ (h2 >>> 16), F_K1);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), F_K2);\n\n return P_K1 * (P_K2 & h2) + (h1 >>> 0);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";qqBAAA,6GAAM,QAAU,WAChB,IAAM,QAAU,WAChB,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,QAiBN,SAAS,OAAO,IAAa,KAAO,EAAW,CACpD,IAAI,GAAK,QAAU,KACnB,IAAI,GAAK,QAAU,KAEnB,QAAS,EAAI,EAAG,GAAI,EAAI,IAAI,OAAQ,IAAK,CACvC,GAAK,IAAI,WAAW,CAAC,EACrB,GAAK,KAAK,KAAK,GAAK,GAAI,IAAI,EAC5B,GAAK,KAAK,KAAK,GAAK,GAAI,IAAI,CAC9B,CAEA,GAAK,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACrC,IAAM,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACtC,GAAK,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACrC,IAAM,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EAEtC,OAAO,MAAQ,KAAO,KAAO,KAAO,EACtC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
/* @alwatr/cyrb53 v1.0.
|
|
2
|
-
|
|
3
|
-
// src/main.ts
|
|
4
|
-
var H1_SEED = 3735928559;
|
|
5
|
-
var H2_SEED = 1103547991;
|
|
6
|
-
var M_K1 = 2654435761;
|
|
7
|
-
var M_K2 = 1597334677;
|
|
8
|
-
var F_K1 = 2246822507;
|
|
9
|
-
var F_K2 = 3266489909;
|
|
10
|
-
var P_K1 = 4294967296;
|
|
11
|
-
var P_K2 = 2097151;
|
|
12
|
-
function cyrb53(str, seed = 0) {
|
|
13
|
-
let h1 = H1_SEED ^ seed;
|
|
14
|
-
let h2 = H2_SEED ^ seed;
|
|
15
|
-
for (let i = 0, ch; i < str.length; i++) {
|
|
16
|
-
ch = str.charCodeAt(i);
|
|
17
|
-
h1 = Math.imul(h1 ^ ch, M_K1);
|
|
18
|
-
h2 = Math.imul(h2 ^ ch, M_K2);
|
|
19
|
-
}
|
|
20
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, F_K1);
|
|
21
|
-
h1 ^= Math.imul(h2 ^ h2 >>> 13, F_K2);
|
|
22
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, F_K1);
|
|
23
|
-
h2 ^= Math.imul(h1 ^ h1 >>> 13, F_K2);
|
|
24
|
-
return P_K1 * (P_K2 & h2) + (h1 >>> 0);
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
cyrb53
|
|
28
|
-
};
|
|
1
|
+
/* @alwatr/cyrb53 v1.0.1 */
|
|
2
|
+
var H1_SEED=3735928559;var H2_SEED=1103547991;var M_K1=2654435761;var M_K2=1597334677;var F_K1=2246822507;var F_K2=3266489909;var P_K1=4294967296;var P_K2=2097151;function cyrb53(str,seed=0){let h1=H1_SEED^seed;let h2=H2_SEED^seed;for(let i=0,ch;i<str.length;i++){ch=str.charCodeAt(i);h1=Math.imul(h1^ch,M_K1);h2=Math.imul(h2^ch,M_K2)}h1=Math.imul(h1^h1>>>16,F_K1);h1^=Math.imul(h2^h2>>>13,F_K2);h2=Math.imul(h2^h2>>>16,F_K1);h2^=Math.imul(h1^h1>>>13,F_K2);return P_K1*(P_K2&h2)+(h1>>>0)}export{cyrb53};
|
|
29
3
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["const H1_SEED = 0xdeadbeef;\nconst H2_SEED = 0x41c6ce57;\nconst M_K1 = 2654435761;\nconst M_K2 = 1597334677;\nconst F_K1 = 2246822507;\nconst F_K2 = 3266489909;\nconst P_K1 = 4294967296; // 2^32\nconst P_K2 = 2097151; // 2^21 - 1\n\n/**\n * cyrb53: A modern, high-quality, and fast 53-bit string hash function.\n *\n * Excellent collision resistance due to its large output space.\n * The best choice for new general-purpose hashing needs in JS/TS.\n *\n * @param str The input string.\n * @param seed An optional seed value.\n * @returns A 53-bit hash number.\n *\n * @example\n * ```ts\n * const hash = cyrb53('some string');\n * ```\n */\nexport function cyrb53(str: string, seed = 0): number {\n let h1 = H1_SEED ^ seed;\n let h2 = H2_SEED ^ seed;\n\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, M_K1);\n h2 = Math.imul(h2 ^ ch, M_K2);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), F_K1);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), F_K2);\n h2 = Math.imul(h2 ^ (h2 >>> 16), F_K1);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), F_K2);\n\n return P_K1 * (P_K2 & h2) + (h1 >>> 0);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA,IAAM,QAAU,WAChB,IAAM,QAAU,WAChB,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,WACb,IAAM,KAAO,QAiBN,SAAS,OAAO,IAAa,KAAO,EAAW,CACpD,IAAI,GAAK,QAAU,KACnB,IAAI,GAAK,QAAU,KAEnB,QAAS,EAAI,EAAG,GAAI,EAAI,IAAI,OAAQ,IAAK,CACvC,GAAK,IAAI,WAAW,CAAC,EACrB,GAAK,KAAK,KAAK,GAAK,GAAI,IAAI,EAC5B,GAAK,KAAK,KAAK,GAAK,GAAI,IAAI,CAC9B,CAEA,GAAK,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACrC,IAAM,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACtC,GAAK,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EACrC,IAAM,KAAK,KAAK,GAAM,KAAO,GAAK,IAAI,EAEtC,OAAO,MAAQ,KAAO,KAAO,KAAO,EACtC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/cyrb53",
|
|
3
3
|
"description": "A modern, high-quality, and fast 53-bit string hash function.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Alwatr/nanolib/issues",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@alwatr/nano-build": "6.
|
|
8
|
+
"@alwatr/nano-build": "6.2.0",
|
|
9
9
|
"@alwatr/prettier-config": "5.0.3",
|
|
10
10
|
"@alwatr/tsconfig-base": "6.0.1",
|
|
11
11
|
"@alwatr/type-helper": "6.0.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
},
|
|
61
61
|
"type": "module",
|
|
62
62
|
"types": "./dist/main.d.ts",
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e081773e1ba6bf1c62c07d7dc966b174fa7dd3ea"
|
|
64
64
|
}
|