mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-18 13:43:27 +00:00
* Tgui: More common components in ts (#83098) ## About The Pull Request Converts more of common into typescript, with some tests ## Why It's Good For The Game Typescript,,,, * Tgui: More common components in ts --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
25 lines
487 B
TypeScript
25 lines
487 B
TypeScript
/**
|
|
* @file
|
|
* @copyright 2020 Aleksej Komarov
|
|
* @license MIT
|
|
*/
|
|
|
|
/**
|
|
* Creates a UUID v4 string
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* createUuid(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
|
|
* ```
|
|
*/
|
|
export function createUuid(): string {
|
|
let d = new Date().getTime();
|
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
const r = (d + Math.random() * 16) % 16 | 0;
|
|
d = Math.floor(d / 16);
|
|
|
|
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
|
|
});
|
|
}
|