fix: proper browser env check...
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable */
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import copy from 'fast-copy';
|
||||
import { Buffer } from 'redstone-isomorphic';
|
||||
import { randomUUID } from 'crypto';
|
||||
import {Buffer} from 'redstone-isomorphic';
|
||||
import {randomUUID} from 'crypto';
|
||||
|
||||
export const sleep = (ms: number): Promise<void> => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
@@ -78,9 +78,11 @@ export function bufToBn(buf: Buffer) {
|
||||
}
|
||||
|
||||
export function isomorphicRandomUUID() {
|
||||
if (self.crypto) {
|
||||
if (isBrowser() && self.crypto) {
|
||||
return self.crypto.randomUUID();
|
||||
} else {
|
||||
return randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
|
||||
|
||||
Reference in New Issue
Block a user