Skip to content

Commit

Permalink
fix: use same global to inject process.hrtime
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 13, 2020
1 parent f06a437 commit 0303912
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/targets/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { SLSTarget } from '../config'
const polyfill = `
const exports = {};
const module = { exports };
const global = { process: {} };
const window = global;
const global = typeof globalThis !== 'undefined' ? globalThis : "undefined" !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
global.process = global.process || {};
(function(){const o=Date.now(),t=()=>Date.now()-o;global.process.hrtime=o=>{const e=Math.floor(.001*(Date.now()-t())),n=.001*t();let a=Math.floor(n)+e,r=Math.floor(n%1*1e9);return o&&(a-=o[0],r-=o[1],r<0&&(a--,r+=1e9)),[a,r]};})();
`

Expand Down

0 comments on commit 0303912

Please sign in to comment.