@alwatr/cyrb53 1.0.6 โ 1.0.8
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 +12 -0
- package/dist/main.cjs +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +10 -9
- package/src/main.test.js +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.8](https://github.com/Alwatr/nanolib/compare/@alwatr/cyrb53@1.0.7...@alwatr/cyrb53@1.0.8) (2025-10-06)
|
|
7
|
+
|
|
8
|
+
### ๐ Dependencies update
|
|
9
|
+
|
|
10
|
+
* bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
|
|
11
|
+
|
|
12
|
+
## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/cyrb53@1.0.6...@alwatr/cyrb53@1.0.7) (2025-09-27)
|
|
13
|
+
|
|
14
|
+
### ๐งน Miscellaneous Chores
|
|
15
|
+
|
|
16
|
+
* exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
|
|
17
|
+
|
|
6
18
|
## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/cyrb53@1.0.5...@alwatr/cyrb53@1.0.6) (2025-09-22)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @alwatr/cyrb53
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ๐ฆ @alwatr/cyrb53 v1.0.
|
|
2
|
-
__dev_mode__: console.debug("๐ฆ @alwatr/cyrb53 v1.0.
|
|
1
|
+
/** ๐ฆ @alwatr/cyrb53 v1.0.8 */
|
|
2
|
+
__dev_mode__: console.debug("๐ฆ @alwatr/cyrb53 v1.0.8");
|
|
3
3
|
"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});
|
|
4
4
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ๐ฆ @alwatr/cyrb53 v1.0.
|
|
2
|
-
__dev_mode__: console.debug("๐ฆ @alwatr/cyrb53 v1.0.
|
|
1
|
+
/** ๐ฆ @alwatr/cyrb53 v1.0.8 */
|
|
2
|
+
__dev_mode__: console.debug("๐ฆ @alwatr/cyrb53 v1.0.8");
|
|
3
3
|
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};
|
|
4
4
|
//# sourceMappingURL=main.mjs.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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.8",
|
|
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.3.
|
|
9
|
-
"@alwatr/prettier-config": "5.0.
|
|
10
|
-
"@alwatr/tsconfig-base": "6.0.
|
|
11
|
-
"@alwatr/type-helper": "6.1.
|
|
12
|
-
"@jest/globals": "^30.
|
|
13
|
-
"typescript": "^5.9.
|
|
8
|
+
"@alwatr/nano-build": "6.3.5",
|
|
9
|
+
"@alwatr/prettier-config": "5.0.5",
|
|
10
|
+
"@alwatr/tsconfig-base": "6.0.3",
|
|
11
|
+
"@alwatr/type-helper": "6.1.5",
|
|
12
|
+
"@jest/globals": "^30.2.0",
|
|
13
|
+
"typescript": "^5.9.3"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
|
|
24
24
|
"LICENSE",
|
|
25
|
-
"!demo/**/*"
|
|
25
|
+
"!demo/**/*",
|
|
26
|
+
"!**/*.test.js"
|
|
26
27
|
],
|
|
27
28
|
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/cyrb53#readme",
|
|
28
29
|
"keywords": [
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"sideEffects": false,
|
|
62
63
|
"type": "module",
|
|
63
64
|
"types": "./dist/main.d.ts",
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "b141732f4dab13542e3cc99926a250fd5c74bad3"
|
|
65
66
|
}
|
package/src/main.test.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {cyrb53} from '@alwatr/cyrb53';
|
|
2
|
-
import {describe, it, expect} from '@jest/globals';
|
|
3
|
-
|
|
4
|
-
describe('cyrb53', () => {
|
|
5
|
-
it('should generate a numeric hash for a string input', () => {
|
|
6
|
-
const hash = cyrb53('test');
|
|
7
|
-
expect(typeof hash).toBe('number');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should generate a consistent hash for the same input', () => {
|
|
11
|
-
const input = 'alwatr_org';
|
|
12
|
-
const hash1 = cyrb53(input);
|
|
13
|
-
const hash2 = cyrb53(input);
|
|
14
|
-
expect(hash1).toBe(hash2);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should generate different hashes for different inputs', () => {
|
|
18
|
-
const hash1 = cyrb53('hello');
|
|
19
|
-
const hash2 = cyrb53('world');
|
|
20
|
-
expect(hash1).not.toBe(hash2);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should handle empty strings', () => {
|
|
24
|
-
const hash = cyrb53('');
|
|
25
|
-
// The hash for an empty string with seed 0 is a known value
|
|
26
|
-
expect(hash).toBe(3338908027751811);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle long strings', () => {
|
|
30
|
-
const longString = 'a'.repeat(1000);
|
|
31
|
-
const hash = cyrb53(longString);
|
|
32
|
-
expect(typeof hash).toBe('number');
|
|
33
|
-
expect(cyrb53(longString)).toBe(hash); // consistency check
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should handle special characters and unicode', () => {
|
|
37
|
-
const specialString = '!@#$%^&*()_+-=~`[]{}|;:",./<>? \t\n\r';
|
|
38
|
-
const unicodeString = '๐๐๐';
|
|
39
|
-
const hash1 = cyrb53(specialString);
|
|
40
|
-
const hash2 = cyrb53(unicodeString);
|
|
41
|
-
expect(typeof hash1).toBe('number');
|
|
42
|
-
expect(typeof hash2).toBe('number');
|
|
43
|
-
expect(hash1).not.toBe(hash2);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should produce different hashes for the same input with different seeds', () => {
|
|
47
|
-
const input = 'alwatr_org';
|
|
48
|
-
const hash1 = cyrb53(input, 0);
|
|
49
|
-
const hash2 = cyrb53(input, 12345);
|
|
50
|
-
expect(hash1).not.toBe(hash2);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should produce a consistent hash for the same input and seed', () => {
|
|
54
|
-
const input = 'alwatr_org';
|
|
55
|
-
const seed = 9876;
|
|
56
|
-
const hash1 = cyrb53(input, seed);
|
|
57
|
-
const hash2 = cyrb53(input, seed);
|
|
58
|
-
expect(hash1).toBe(hash2);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should produce a known value for a known input and seed', () => {
|
|
62
|
-
// This acts as a regression test to ensure the algorithm doesn't change.
|
|
63
|
-
expect(cyrb53('Alwatr')).toBe(3747986774435305);
|
|
64
|
-
expect(cyrb53('Alwatr', 123)).toBe(3798651724839550);
|
|
65
|
-
});
|
|
66
|
-
});
|