@alwatr/djb2-hash 1.1.17 โ†’ 2.0.0

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/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* ๐Ÿ“ฆ @alwatr/djb2-hash v2.0.0 */
2
+ function f(d){let b=5381;for(let c=d.length-1;c>=0;c--)b=(b<<5)+b^d.charCodeAt(c);return b>>>0}export{f as djb2Hash};
3
+
4
+ //# debugId=6E05DA394BDA707B64756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * DJB2 hash algorithm but faster!\n *\n * This implementation is based on Daniel J. Bernstein's popular 'times 33' hash algorithm,\n * commonly known as DJB2. It's known for its simplicity, speed, and good distribution properties\n * for short strings, making it suitable for general purpose hashing needs.\n *\n * Performance improvements in this version:\n * - Uses right-to-left iteration to avoid repeated length lookups\n * - Employs bit shifting operations for faster computation\n * - Final right shift ensures unsigned 32-bit integer output\n *\n * @param {string} str - The input string to be hashed\n * @returns {number} A 32-bit unsigned integer hash value\n *\n * @example\n * // Returns a numeric hash value\n * const hashValue = djb2Hash(\"hello world\");\n */\nexport function djb2Hash(str: string): number {\n // 5381 is a prime number used as initial value in the DJB2 algorithm\n let hashValue = 5381;\n\n // Reverse loop for better performance - avoids repeated length property lookup\n for (let i = str.length - 1; i >= 0; i--) {\n // Using left shift (*2) and addition instead of multiplication by 33\n // (hash * 33) is equivalent to ((hash << 5) + hash)\n hashValue = ((hashValue << 5) + hashValue) ^ str.charCodeAt(i);\n }\n\n return hashValue >>> 0;\n}\n"
6
+ ],
7
+ "mappings": ";AAmBO,SAAS,CAAQ,CAAC,EAAqB,CAE5C,IAAI,EAAY,KAGhB,QAAS,EAAI,EAAI,OAAS,EAAG,GAAK,EAAG,IAGnC,GAAc,GAAa,GAAK,EAAa,EAAI,WAAW,CAAC,EAG/D,OAAO,IAAc",
8
+ "debugId": "6E05DA394BDA707B64756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@alwatr/djb2-hash",
3
3
  "description": "A fast, non-cryptographic hash function based on DJB2.",
4
- "version": "1.1.17",
4
+ "version": "2.0.0",
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.4.2",
9
- "@alwatr/prettier-config": "6.0.2",
10
- "@alwatr/tsconfig-base": "6.0.4",
8
+ "@alwatr/nano-build": "7.0.0",
9
+ "@alwatr/prettier-config": "7.0.0",
10
+ "@alwatr/tsconfig-base": "7.0.0",
11
11
  "typescript": "^5.9.3"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/main.d.ts",
16
- "import": "./dist/main.mjs",
17
- "require": "./dist/main.cjs"
16
+ "default": "./dist/main.js"
18
17
  }
19
18
  },
20
19
  "files": [
21
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
20
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
21
+ "README.md",
22
22
  "LICENSE",
23
23
  "!demo/**/*",
24
24
  "!**/*.test.js"
@@ -44,8 +44,6 @@
44
44
  "utils"
45
45
  ],
46
46
  "license": "MPL-2.0",
47
- "main": "./dist/main.cjs",
48
- "module": "./dist/main.mjs",
49
47
  "prettier": "@alwatr/prettier-config",
50
48
  "publishConfig": {
51
49
  "access": "public"
@@ -58,14 +56,14 @@
58
56
  "scripts": {
59
57
  "b": "bun run build",
60
58
  "build": "bun run build:ts && bun run build:es",
61
- "build:es": "nano-build --preset=module",
59
+ "build:es": "nano-build --preset=module src/main.ts",
62
60
  "build:ts": "tsc --build",
63
61
  "c": "bun run clean",
64
62
  "cb": "bun run clean && bun run build",
65
63
  "clean": "rm -rfv dist *.tsbuildinfo",
66
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
64
+ "d": "bun run build:es && bun",
67
65
  "t": "bun run test",
68
- "test": "echo test-skipped",
66
+ "test": "bun test",
69
67
  "w": "bun run watch",
70
68
  "watch": "bun run watch:ts & bun run watch:es",
71
69
  "watch:es": "bun run build:es --watch",
@@ -74,5 +72,5 @@
74
72
  "sideEffects": false,
75
73
  "type": "module",
76
74
  "types": "./dist/main.d.ts",
77
- "gitHead": "c3889e3756b0a0f9b935a1b702a1373ac52cb379"
75
+ "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
78
76
  }
package/src/main.ts ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * DJB2 hash algorithm but faster!
3
+ *
4
+ * This implementation is based on Daniel J. Bernstein's popular 'times 33' hash algorithm,
5
+ * commonly known as DJB2. It's known for its simplicity, speed, and good distribution properties
6
+ * for short strings, making it suitable for general purpose hashing needs.
7
+ *
8
+ * Performance improvements in this version:
9
+ * - Uses right-to-left iteration to avoid repeated length lookups
10
+ * - Employs bit shifting operations for faster computation
11
+ * - Final right shift ensures unsigned 32-bit integer output
12
+ *
13
+ * @param {string} str - The input string to be hashed
14
+ * @returns {number} A 32-bit unsigned integer hash value
15
+ *
16
+ * @example
17
+ * // Returns a numeric hash value
18
+ * const hashValue = djb2Hash("hello world");
19
+ */
20
+ export function djb2Hash(str: string): number {
21
+ // 5381 is a prime number used as initial value in the DJB2 algorithm
22
+ let hashValue = 5381;
23
+
24
+ // Reverse loop for better performance - avoids repeated length property lookup
25
+ for (let i = str.length - 1; i >= 0; i--) {
26
+ // Using left shift (*2) and addition instead of multiplication by 33
27
+ // (hash * 33) is equivalent to ((hash << 5) + hash)
28
+ hashValue = ((hashValue << 5) + hashValue) ^ str.charCodeAt(i);
29
+ }
30
+
31
+ return hashValue >>> 0;
32
+ }
package/CHANGELOG.md DELETED
@@ -1,94 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [1.1.17](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.16...@alwatr/djb2-hash@1.1.17) (2026-03-16)
7
-
8
- ### ๐Ÿ”จ Code Refactoring
9
-
10
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
11
-
12
- ## [1.1.16](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.15...@alwatr/djb2-hash@1.1.16) (2026-02-18)
13
-
14
- **Note:** Version bump only for package @alwatr/djb2-hash
15
-
16
- ## [1.1.15](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.14...@alwatr/djb2-hash@1.1.15) (2025-12-23)
17
-
18
- **Note:** Version bump only for package @alwatr/djb2-hash
19
-
20
- ## [1.1.14](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.13...@alwatr/djb2-hash@1.1.14) (2025-12-13)
21
-
22
- **Note:** Version bump only for package @alwatr/djb2-hash
23
-
24
- ## [1.1.13](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.12...@alwatr/djb2-hash@1.1.13) (2025-12-10)
25
-
26
- **Note:** Version bump only for package @alwatr/djb2-hash
27
-
28
- ## [1.1.12](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.11...@alwatr/djb2-hash@1.1.12) (2025-11-18)
29
-
30
- ### ๐Ÿ”จ Code Refactoring
31
-
32
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
33
-
34
- ## [1.1.11](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.10...@alwatr/djb2-hash@1.1.11) (2025-11-15)
35
-
36
- **Note:** Version bump only for package @alwatr/djb2-hash
37
-
38
- ## [1.1.10](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.9...@alwatr/djb2-hash@1.1.10) (2025-11-15)
39
-
40
- **Note:** Version bump only for package @alwatr/djb2-hash
41
-
42
- ## [1.1.9](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.8...@alwatr/djb2-hash@1.1.9) (2025-11-04)
43
-
44
- **Note:** Version bump only for package @alwatr/djb2-hash
45
-
46
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.7...@alwatr/djb2-hash@1.1.8) (2025-10-06)
47
-
48
- ### ๐Ÿ”— Dependencies update
49
-
50
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
51
-
52
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.6...@alwatr/djb2-hash@1.1.7) (2025-09-27)
53
-
54
- ### ๐Ÿงน Miscellaneous Chores
55
-
56
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
57
-
58
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.5...@alwatr/djb2-hash@1.1.6) (2025-09-22)
59
-
60
- **Note:** Version bump only for package @alwatr/djb2-hash
61
-
62
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.4...@alwatr/djb2-hash@1.1.5) (2025-09-22)
63
-
64
- **Note:** Version bump only for package @alwatr/djb2-hash
65
-
66
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.3...@alwatr/djb2-hash@1.1.4) (2025-09-21)
67
-
68
- **Note:** Version bump only for package @alwatr/djb2-hash
69
-
70
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.2...@alwatr/djb2-hash@1.1.3) (2025-09-20)
71
-
72
- ### ๐Ÿ› Bug Fixes
73
-
74
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
75
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
76
-
77
- ### ๐Ÿงน Miscellaneous Chores
78
-
79
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
80
- * reorder keywords in package.json for consistency ([095b9c9](https://github.com/Alwatr/nanolib/commit/095b9c9c2d79d3a8bf3ebff7315a3becb8580ea1))
81
-
82
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.1...@alwatr/djb2-hash@1.1.2) (2025-09-19)
83
-
84
- **Note:** Version bump only for package @alwatr/djb2-hash
85
-
86
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/djb2-hash@1.1.0...@alwatr/djb2-hash@1.1.1) (2025-09-15)
87
-
88
- **Note:** Version bump only for package @alwatr/djb2-hash
89
-
90
- ## 1.1.0 (2025-09-14)
91
-
92
- ### โœจ Features
93
-
94
- * add new @alwatr/djb2-hash package ([1718bd7](https://github.com/Alwatr/nanolib/commit/1718bd786d23e13664831f51bfd4e54e5059e710))
package/dist/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- /** ๐Ÿ“ฆ @alwatr/djb2-hash v1.1.17 */
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,{djb2Hash:()=>djb2Hash});module.exports=__toCommonJS(main_exports);function djb2Hash(str){let hashValue=5381;for(let i=str.length-1;i>=0;i--){hashValue=(hashValue<<5)+hashValue^str.charCodeAt(i)}return hashValue>>>0}0&&(module.exports={djb2Hash});
3
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["/**\n * DJB2 hash algorithm but faster!\n *\n * This implementation is based on Daniel J. Bernstein's popular 'times 33' hash algorithm,\n * commonly known as DJB2. It's known for its simplicity, speed, and good distribution properties\n * for short strings, making it suitable for general purpose hashing needs.\n *\n * Performance improvements in this version:\n * - Uses right-to-left iteration to avoid repeated length lookups\n * - Employs bit shifting operations for faster computation\n * - Final right shift ensures unsigned 32-bit integer output\n *\n * @param {string} str - The input string to be hashed\n * @returns {number} A 32-bit unsigned integer hash value\n *\n * @example\n * // Returns a numeric hash value\n * const hashValue = djb2Hash(\"hello world\");\n */\nexport function djb2Hash(str: string): number {\n // 5381 is a prime number used as initial value in the DJB2 algorithm\n let hashValue = 5381;\n\n // Reverse loop for better performance - avoids repeated length property lookup\n for (let i = str.length - 1; i >= 0; i--) {\n // Using left shift (*2) and addition instead of multiplication by 33\n // (hash * 33) is equivalent to ((hash << 5) + hash)\n hashValue = ((hashValue << 5) + hashValue) ^ str.charCodeAt(i);\n }\n\n return hashValue >>> 0;\n}\n"],
5
- "mappings": ";qqBAAA,6GAmBO,SAAS,SAAS,IAAqB,CAE5C,IAAI,UAAY,KAGhB,QAAS,EAAI,IAAI,OAAS,EAAG,GAAK,EAAG,IAAK,CAGxC,WAAc,WAAa,GAAK,UAAa,IAAI,WAAW,CAAC,CAC/D,CAEA,OAAO,YAAc,CACvB",
6
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,3 +0,0 @@
1
- /** ๐Ÿ“ฆ @alwatr/djb2-hash v1.1.17 */
2
- function djb2Hash(str){let hashValue=5381;for(let i=str.length-1;i>=0;i--){hashValue=(hashValue<<5)+hashValue^str.charCodeAt(i)}return hashValue>>>0}export{djb2Hash};
3
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["/**\n * DJB2 hash algorithm but faster!\n *\n * This implementation is based on Daniel J. Bernstein's popular 'times 33' hash algorithm,\n * commonly known as DJB2. It's known for its simplicity, speed, and good distribution properties\n * for short strings, making it suitable for general purpose hashing needs.\n *\n * Performance improvements in this version:\n * - Uses right-to-left iteration to avoid repeated length lookups\n * - Employs bit shifting operations for faster computation\n * - Final right shift ensures unsigned 32-bit integer output\n *\n * @param {string} str - The input string to be hashed\n * @returns {number} A 32-bit unsigned integer hash value\n *\n * @example\n * // Returns a numeric hash value\n * const hashValue = djb2Hash(\"hello world\");\n */\nexport function djb2Hash(str: string): number {\n // 5381 is a prime number used as initial value in the DJB2 algorithm\n let hashValue = 5381;\n\n // Reverse loop for better performance - avoids repeated length property lookup\n for (let i = str.length - 1; i >= 0; i--) {\n // Using left shift (*2) and addition instead of multiplication by 33\n // (hash * 33) is equivalent to ((hash << 5) + hash)\n hashValue = ((hashValue << 5) + hashValue) ^ str.charCodeAt(i);\n }\n\n return hashValue >>> 0;\n}\n"],
5
- "mappings": ";AAmBO,SAAS,SAAS,IAAqB,CAE5C,IAAI,UAAY,KAGhB,QAAS,EAAI,IAAI,OAAS,EAAG,GAAK,EAAG,IAAK,CAGxC,WAAc,WAAa,GAAK,UAAa,IAAI,WAAW,CAAC,CAC/D,CAEA,OAAO,YAAc,CACvB",
6
- "names": []
7
- }