Skip to content

Commit

Permalink
add judgment on global.performance
Browse files Browse the repository at this point in the history
  • Loading branch information
peng committed Mar 20, 2024
1 parent d33394d commit c532a07
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
if (typeof window === 'undefined') {
if (!global.crypto) {
global.crypto = {
async getRandomValues(b) {
const { randomFillSync } = await import('crypto');
randomFillSync(b);
}
};
}
global.performance = {
!global.crypto && (global.crypto = {
async getRandomValues(b) {
const { randomFillSync } = await import('crypto');
randomFillSync(b);
}
});
!global.performance && (global.performance = {
now() {
const [sec, nsec] = process.hrtime();
return sec * 1000 + nsec / 1000000;
}
};
});
}
(() => {
const enosys = () => {
Expand Down

0 comments on commit c532a07

Please sign in to comment.