Node: Replace global with globalThis

This commit is contained in:
Cohee
2024-10-18 09:13:25 +00:00
parent 6a5828f2c7
commit a32dd436d7
9 changed files with 17 additions and 14 deletions

View File

@ -305,8 +305,8 @@ export const color = {
* @returns {string} A UUIDv4 string
*/
export function uuidv4() {
if ('crypto' in global && 'randomUUID' in global.crypto) {
return global.crypto.randomUUID();
if ('crypto' in globalThis && 'randomUUID' in globalThis.crypto) {
return globalThis.crypto.randomUUID();
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0;