@alwatr/djb2-hash 2.0.1 → 9.1.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/LICENSE CHANGED
@@ -2,6 +2,7 @@ Mozilla Public License Version 2.0
2
2
  ==================================
3
3
 
4
4
  1. Definitions
5
+
5
6
  --------------
6
7
 
7
8
  1.1. "Contributor"
@@ -83,7 +84,8 @@ Mozilla Public License Version 2.0
83
84
  fifty percent (50%) of the outstanding shares or beneficial
84
85
  ownership of such entity.
85
86
 
86
- 2. License Grants and Conditions
87
+ 1. License Grants and Conditions
88
+
87
89
  --------------------------------
88
90
 
89
91
  2.1. Grants
@@ -154,7 +156,8 @@ equivalents.
154
156
  Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
157
  in Section 2.1.
156
158
 
157
- 3. Responsibilities
159
+ 1. Responsibilities
160
+
158
161
  -------------------
159
162
 
160
163
  3.1. Distribution of Source Form
@@ -216,7 +219,8 @@ indemnity or liability terms You offer. You may include additional
216
219
  disclaimers of warranty and limitations of liability specific to any
217
220
  jurisdiction.
218
221
 
219
- 4. Inability to Comply Due to Statute or Regulation
222
+ 1. Inability to Comply Due to Statute or Regulation
223
+
220
224
  ---------------------------------------------------
221
225
 
222
226
  If it is impossible for You to comply with any of the terms of this
@@ -229,7 +233,8 @@ Software under this License. Except to the extent prohibited by statute
229
233
  or regulation, such description must be sufficiently detailed for a
230
234
  recipient of ordinary skill to be able to understand it.
231
235
 
232
- 5. Termination
236
+ 1. Termination
237
+
233
238
  --------------
234
239
 
235
240
  5.1. The rights granted under this License will terminate automatically
@@ -259,48 +264,53 @@ have been validly granted by You or Your distributors under this License
259
264
  prior to termination shall survive termination.
260
265
 
261
266
  ************************************************************************
267
+
262
268
  * *
263
- * 6. Disclaimer of Warranty *
264
- * ------------------------- *
269
+ * 1. Disclaimer of Warranty *
270
+ * ------------------------- *
265
271
  * *
266
- * Covered Software is provided under this License on an "as is" *
267
- * basis, without warranty of any kind, either expressed, implied, or *
268
- * statutory, including, without limitation, warranties that the *
269
- * Covered Software is free of defects, merchantable, fit for a *
270
- * particular purpose or non-infringing. The entire risk as to the *
271
- * quality and performance of the Covered Software is with You. *
272
- * Should any Covered Software prove defective in any respect, You *
273
- * (not any Contributor) assume the cost of any necessary servicing, *
274
- * repair, or correction. This disclaimer of warranty constitutes an *
275
- * essential part of this License. No use of any Covered Software is *
276
- * authorized under this License except under this disclaimer. *
272
+ * Covered Software is provided under this License on an "as is" *
273
+ * basis, without warranty of any kind, either expressed, implied, or *
274
+ * statutory, including, without limitation, warranties that the *
275
+ * Covered Software is free of defects, merchantable, fit for a *
276
+ * particular purpose or non-infringing. The entire risk as to the *
277
+ * quality and performance of the Covered Software is with You. *
278
+ * Should any Covered Software prove defective in any respect, You *
279
+ * (not any Contributor) assume the cost of any necessary servicing, *
280
+ * repair, or correction. This disclaimer of warranty constitutes an *
281
+ * essential part of this License. No use of any Covered Software is *
282
+ * authorized under this License except under this disclaimer. *
277
283
  * *
284
+
278
285
  ************************************************************************
279
286
 
280
287
  ************************************************************************
288
+
281
289
  * *
282
- * 7. Limitation of Liability *
283
- * -------------------------- *
290
+ * 1. Limitation of Liability *
291
+ * -------------------------- *
284
292
  * *
285
- * Under no circumstances and under no legal theory, whether tort *
286
- * (including negligence), contract, or otherwise, shall any *
287
- * Contributor, or anyone who distributes Covered Software as *
288
- * permitted above, be liable to You for any direct, indirect, *
289
- * special, incidental, or consequential damages of any character *
290
- * including, without limitation, damages for lost profits, loss of *
291
- * goodwill, work stoppage, computer failure or malfunction, or any *
292
- * and all other commercial damages or losses, even if such party *
293
- * shall have been informed of the possibility of such damages. This *
294
- * limitation of liability shall not apply to liability for death or *
295
- * personal injury resulting from such party's negligence to the *
296
- * extent applicable law prohibits such limitation. Some *
297
- * jurisdictions do not allow the exclusion or limitation of *
298
- * incidental or consequential damages, so this exclusion and *
299
- * limitation may not apply to You. *
293
+ * Under no circumstances and under no legal theory, whether tort *
294
+ * (including negligence), contract, or otherwise, shall any *
295
+ * Contributor, or anyone who distributes Covered Software as *
296
+ * permitted above, be liable to You for any direct, indirect, *
297
+ * special, incidental, or consequential damages of any character *
298
+ * including, without limitation, damages for lost profits, loss of *
299
+ * goodwill, work stoppage, computer failure or malfunction, or any *
300
+ * and all other commercial damages or losses, even if such party *
301
+ * shall have been informed of the possibility of such damages. This *
302
+ * limitation of liability shall not apply to liability for death or *
303
+ * personal injury resulting from such party's negligence to the *
304
+ * extent applicable law prohibits such limitation. Some *
305
+ * jurisdictions do not allow the exclusion or limitation of *
306
+ * incidental or consequential damages, so this exclusion and *
307
+ * limitation may not apply to You. *
300
308
  * *
309
+
301
310
  ************************************************************************
302
311
 
303
- 8. Litigation
312
+ 1. Litigation
313
+
304
314
  -------------
305
315
 
306
316
  Any litigation relating to this License may be brought only in the
@@ -310,7 +320,8 @@ jurisdiction, without reference to its conflict-of-law provisions.
310
320
  Nothing in this Section shall prevent a party's ability to bring
311
321
  cross-claims or counter-claims.
312
322
 
313
- 9. Miscellaneous
323
+ 1. Miscellaneous
324
+
314
325
  ----------------
315
326
 
316
327
  This License represents the complete agreement concerning the subject
@@ -320,7 +331,8 @@ necessary to make it enforceable. Any law or regulation which provides
320
331
  that the language of a contract shall be construed against the drafter
321
332
  shall not be used to construe this License against a Contributor.
322
333
 
323
- 10. Versions of the License
334
+ 1. Versions of the License
335
+
324
336
  ---------------------------
325
337
 
326
338
  10.1. New Versions
@@ -357,7 +369,7 @@ Exhibit A - Source Code Form License Notice
357
369
 
358
370
  This Source Code Form is subject to the terms of the Mozilla Public
359
371
  License, v. 2.0. If a copy of the MPL was not distributed with this
360
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
372
+ file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
361
373
 
362
374
  If it is not possible or desirable to put the notice in a particular
363
375
  file, then You may include the notice in a location (such as a LICENSE
@@ -370,4 +382,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
382
  ---------------------------------------------------------
371
383
 
372
384
  This Source Code Form is "Incompatible With Secondary Licenses", as
373
- defined by the Mozilla Public License, v. 2.0.
385
+ defined by the Mozilla Public License, v. 2.0.
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- /* 📦 @alwatr/djb2-hash v2.0.1 */
1
+ /* 📦 @alwatr/djb2-hash v9.1.0 */
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=D80F20B9F54D403864756E2164756E21
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": "D80F20B9F54D403864756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,52 +1,53 @@
1
1
  {
2
2
  "name": "@alwatr/djb2-hash",
3
- "version": "2.0.1",
3
+ "version": "9.1.0",
4
4
  "description": "A fast, non-cryptographic hash function based on DJB2.",
5
5
  "license": "MPL-2.0",
6
- "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
+ "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
7
7
  "type": "module",
8
8
  "repository": {
9
- "directory": "packages/djb2-hash",
10
9
  "type": "git",
11
- "url": "https://github.com/Alwatr/nanolib"
10
+ "url": "https://github.com/Alwatr/alwatr",
11
+ "directory": "pkg/nanolib/djb2-hash"
12
12
  },
13
- "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/djb2-hash#readme",
14
- "bugs": "https://github.com/Alwatr/nanolib/issues",
13
+ "homepage": "https://github.com/Alwatr/alwatr/tree/main/pkg/nanolib/djb2-hash#readme",
14
+ "bugs": "https://github.com/Alwatr/alwatr/issues",
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/main.d.ts",
18
+ "import": "./dist/main.js",
18
19
  "default": "./dist/main.js"
19
20
  }
20
21
  },
21
22
  "sideEffects": false,
22
23
  "devDependencies": {
23
- "@alwatr/nano-build": "7.0.1",
24
- "@alwatr/prettier-config": "7.0.1",
25
- "@alwatr/tsconfig-base": "8.0.0",
26
- "typescript": "^5.9.3"
24
+ "@alwatr/nano-build": "9.1.0",
25
+ "@alwatr/tsconfig-base": "9.1.0",
26
+ "@alwatr/type-helper": "9.1.0",
27
+ "typescript": "^6.0.2"
27
28
  },
28
29
  "scripts": {
29
30
  "b": "bun run build",
30
31
  "build": "bun run build:ts && bun run build:es",
31
32
  "build:es": "nano-build --preset=module src/main.ts",
32
33
  "build:ts": "tsc --build",
33
- "c": "bun run clean",
34
- "cb": "bun run clean && bun run build",
34
+ "cl": "bun run clean",
35
35
  "clean": "rm -rfv dist *.tsbuildinfo",
36
- "d": "bun run build:es && bun",
36
+ "format": "prettier --write \"src/**/*.ts\"",
37
+ "lint": "eslint src/ --ext .ts",
37
38
  "t": "bun run test",
38
- "test": "bun test",
39
+ "test": "ALWATR_DEBUG=0 bun test",
39
40
  "w": "bun run watch",
40
41
  "watch": "bun run watch:ts & bun run watch:es",
41
42
  "watch:es": "bun run build:es --watch",
42
43
  "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
43
44
  },
44
45
  "files": [
45
- "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
46
+ "dist",
47
+ "src/**/*.ts",
48
+ "!src/**/*.test.ts",
46
49
  "README.md",
47
- "LICENSE",
48
- "!demo/**/*",
49
- "!**/*.test.js"
50
+ "LICENSE"
50
51
  ],
51
52
  "publishConfig": {
52
53
  "access": "public"
@@ -70,6 +71,5 @@
70
71
  "utility",
71
72
  "utils"
72
73
  ],
73
- "prettier": "@alwatr/prettier-config",
74
- "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
74
+ "gitHead": "4a25cd3e0499cf61dd761e87d3711abf9b0cd208"
75
75
  }