Skip to content

Commit

Permalink
[random] explicitly state uuidv4 return type - fixes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jun 23, 2023
1 parent bd69ab4 commit edf7423
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions random.js
Expand Up @@ -29,6 +29,10 @@ export const oneOf = arr => arr[math.floor(rand() * arr.length)]

// @ts-ignore
const uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11

/**
* @return {string}
*/
export const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>
(c ^ uint32() & 15 >> c / 4).toString(16)
)

0 comments on commit edf7423

Please sign in to comment.