From a51521d2704c3ca8be0e0ba044d17143ba71f453 Mon Sep 17 00:00:00 2001 From: Kcops11 <64896618+Kcops11@users.noreply.github.com> Date: Sat, 11 Feb 2023 05:36:03 -0600 Subject: docs: improving readability of UUID string (#1622) Co-authored-by: ST-DDT --- src/modules/string/index.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/modules/string') diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts index 6240184c..188c91eb 100644 --- a/src/modules/string/index.ts +++ b/src/modules/string/index.ts @@ -678,14 +678,9 @@ export class StringModule { * @since 8.0.0 */ uuid(): string { - const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; - const replacePlaceholders = (placeholder: string) => { - const random = this.faker.number.int(15); - const value = placeholder === 'x' ? random : (random & 0x3) | 0x8; - return value.toString(16); - }; - - return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders); + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' + .replace(/x/g, () => this.faker.number.hex({ min: 0x0, max: 0xf })) + .replace(/y/g, () => this.faker.number.hex({ min: 0x8, max: 0xb })); } /** -- cgit v1.2.3