diff --git a/lib/uuid.js b/lib/uuid.js index 2e47de7a..18bb4bcb 100644 --- a/lib/uuid.js +++ b/lib/uuid.js @@ -11,6 +11,9 @@ * @return {string} The generate UUID */ export default function uuid() { + if (typeof(self.crypto.randomUUID) === typeof(Function)) { + return self.crypto.randomUUID() + } return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0 const v = c === 'x' ? r : (r & 0x3) | 0x8