Skip to content

Commit 78ae75f

Browse files
committed
chore(*): applying changes from review
1 parent 708bcbc commit 78ae75f

File tree

1 file changed

+4
-7
lines changed
  • projects/igniteui-angular/src/lib/grids/common

1 file changed

+4
-7
lines changed

projects/igniteui-angular/src/lib/grids/common/random.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Use the function to get a random UUID string when secure context is not guaranteed making crypto.randomUUID unavailable.
33
* @returns A random UUID string.
44
*/
5-
export function getUUID() {
6-
if (typeof crypto.randomUUID === "function") {
5+
export function getUUID(): `${string}-${string}-${string}-${string}-${string}` {
6+
if (typeof crypto.randomUUID === 'function') {
77
return crypto.randomUUID();
88
}
99
// Secure fallback using crypto.getRandomValues()
@@ -14,9 +14,6 @@ export function getUUID() {
1414
bytes[6] = (bytes[6] & 0x0f) | 0x40; // Version 4
1515
bytes[8] = (bytes[8] & 0x3f) | 0x80; // Variant 1
1616

17-
return [...bytes]
18-
.map((b, i) =>
19-
[4, 6, 8, 10].includes(i) ? `-${b.toString(16).padStart(2, "0")}` : b.toString(16).padStart(2, "0")
20-
)
21-
.join("");
17+
const a = [...bytes].map((b) => b.toString(16).padStart(2, '0')).join('');
18+
return `${a.slice(0, 8)}-${a.slice(8, 12)}-${a.slice(12, 16)}-${a.slice(16, 20)}-${a.slice(20)}`;
2219
}

0 commit comments

Comments
 (0)