@alwatr/djb2-hash 2.0.1 → 2.0.2

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 CHANGED
@@ -1,5 +1,5 @@
1
- /* 📦 @alwatr/djb2-hash v2.0.1 */
1
+ /* 📦 @alwatr/djb2-hash v2.0.2 */
2
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
3
 
4
- //# debugId=CE7BB669D55BA10A64756E2164756E21
4
+ //# debugId=ED793F1A383747C064756E2164756E21
5
5
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -5,6 +5,6 @@
5
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
6
  ],
7
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": "CE7BB669D55BA10A64756E2164756E21",
8
+ "debugId": "ED793F1A383747C064756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/djb2-hash",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "A fast, non-cryptographic hash function based on DJB2.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
@@ -23,7 +23,7 @@
23
23
  "@alwatr/nano-build": "7.0.1",
24
24
  "@alwatr/prettier-config": "7.0.1",
25
25
  "@alwatr/tsconfig-base": "8.0.0",
26
- "typescript": "^5.9.3"
26
+ "typescript": "^6.0.2"
27
27
  },
28
28
  "scripts": {
29
29
  "b": "bun run build",
@@ -71,5 +71,5 @@
71
71
  "utils"
72
72
  ],
73
73
  "prettier": "@alwatr/prettier-config",
74
- "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
74
+ "gitHead": "95bb13efd0a5f485c6b09f1a911b99492017aed1"
75
75
  }