@plyaz/core 1.0.4 → 1.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.
@@ -7,8 +7,10 @@
7
7
  * @version 1.0.0
8
8
  */
9
9
  /**
10
- * Simple string hashing function for consistent distribution.
11
- * Uses a basic polynomial rolling hash for good distribution.
10
+ * Optimized string hashing function for consistent distribution.
11
+ * Uses FNV-1a hash algorithm for better distribution and performance.
12
+ * FNV-1a provides excellent avalanche properties and is faster than
13
+ * polynomial rolling hash for short to medium strings.
12
14
  *
13
15
  * @param str - String to hash
14
16
  * @returns Positive hash value
@@ -18,6 +20,13 @@
18
20
  * const hash = hashString('user123:AUTH_GOOGLE');
19
21
  * const bucket = hash % 100; // 0-99
20
22
  * ```
23
+ *
24
+ * @remarks
25
+ * FNV-1a algorithm benefits:
26
+ * - Excellent distribution for hash tables
27
+ * - Fast computation with minimal operations
28
+ * - Good avalanche effect (small input changes create large output changes)
29
+ * - Consistent timing reduces timing attack vulnerabilities
21
30
  */
22
31
  export declare function hashString(str: string): number;
23
32
  /**
@@ -72,9 +81,11 @@ export declare const HashUtils: {
72
81
  readonly isInBucketRange: (identifier: string, startBucket: number, endBucket: number, totalBuckets?: number) => boolean;
73
82
  /**
74
83
  * Creates a deterministic random seed from a string.
84
+ * Uses the improved hash function and ensures the seed is within
85
+ * the safe range for JavaScript's Math.random seeding.
75
86
  *
76
87
  * @param str - String to convert to seed
77
- * @returns Deterministic seed value
88
+ * @returns Deterministic seed value (0 to 2^31-1)
78
89
  */
79
90
  readonly createSeed: (str: string) => number;
80
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/utils/common/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAM3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAInF;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;;;;OAMG;qCACqB,MAAM,gBAAe,MAAM,KAAQ,MAAM;IAIjE;;;;;;;;OAQG;2CAEW,MAAM,eACL,MAAM,aACR,MAAM,iBACH,MAAM,KACnB,OAAO;IAKV;;;;;OAKG;+BACe,MAAM,KAAG,MAAM;CAIzB,CAAC"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/utils/common/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmB9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAM3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAInF;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;;;;OAMG;qCACqB,MAAM,gBAAe,MAAM,KAAQ,MAAM;IAIjE;;;;;;;;OAQG;2CAEW,MAAM,eACL,MAAM,aACR,MAAM,iBACH,MAAM,KACnB,OAAO;IAKV;;;;;;;OAOG;+BACe,MAAM,KAAG,MAAM;CAIzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/core",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Shared core logic and utilities for Plyaz apps, services, and future SDKs – centralized, reusable, and scalable.",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -28,10 +28,10 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@nestjs/common": "^11.1.3",
31
- "@plyaz/config": "^1.3.0",
31
+ "@plyaz/config": "1.3.3",
32
32
  "@plyaz/translations": "^1.0.2",
33
33
  "ioredis": "^5.6.1",
34
- "next": "15.3.3",
34
+ "next": "15.4.7",
35
35
  "react": "^19.1.0",
36
36
  "react-dom": "^19.1.0",
37
37
  "viem": "^2.31.7",
@@ -45,8 +45,8 @@
45
45
  "@eslint/markdown": "^6.5.0",
46
46
  "@next/eslint-plugin-next": "^15.0.3",
47
47
  "@plyaz/devtools": "^1.8.0",
48
- "@plyaz/testing": "^1.3.1",
49
- "@plyaz/types": "^1.3.8",
48
+ "@plyaz/testing": "^1.4.2",
49
+ "@plyaz/types": "^1.7.7",
50
50
  "@testing-library/jest-dom": "^6.6.3",
51
51
  "@testing-library/react": "^16.3.0",
52
52
  "@testing-library/user-event": "^14.6.1",