1234567891011121314151617181920212223242526 |
- /**
- * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
- * Be aware Math.random() could cause collisions, but:
- * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
- * @returns a pseudo random id
- */
- export function RandomGUID() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
- const r = (Math.random() * 16) | 0, v = c === "x" ? r : (r & 0x3) | 0x8;
- return v.toString(16);
- });
- }
- /**
- * Class used to manipulate GUIDs
- */
- export const GUID = {
- /**
- * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
- * Be aware Math.random() could cause collisions, but:
- * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
- * @returns a pseudo random id
- */
- // eslint-disable-next-line @typescript-eslint/naming-convention
- RandomId: RandomGUID,
- };
- //# sourceMappingURL=guid.js.map
|