Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 10e47ed

Browse files
authored
feat(uuid): return string if 1 uuid
1 parent a56a378 commit 10e47ed

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/modules/uuid.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
2-
* @function `uuid` - Generate a unique UUID composed of random characters and numbers.
2+
* @function `uuid` - Generate a unique UUID composed of random characters and numbers. UUIDs follow this rule: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
33
* @param { Number } [number] - The amount of UUID's to generate. Condition: **`1 < amount < 64`**
4-
* @returns { Array } - An array of unique UUID's of the amount inputted that follows this rule: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
4+
* @returns { Array } - Returns an array if the amount inputted is above 1.
5+
* @returns { String } - Returns a string if the amount inputted is equal to 1.
56
*/
67

78
function generateUUID(amount) {
8-
const uuids = [];
9+
let uuids = [];
910

1011
let i = 0;
1112

@@ -29,6 +30,8 @@ function generateUUID(amount) {
2930
i++;
3031
} while (i < amount);
3132

33+
if (uuids.length === 1) uuids = uuids[0];
34+
3235
return uuids;
3336
}
3437

0 commit comments

Comments
 (0)