unjs / unenv

🕊️ Convert javaScript code to be runtime agnostic
MIT License
342 stars 18 forks source link

refactor(web/performance): separate polyfill and native exports #214

Closed pi0 closed 1 month ago

pi0 commented 1 month ago

Continuation to #213

Adding _* variant exports that are explicit polyfills to allow mixed usage. (important: constructor is also only possible via polyfill and not with natives)

The polyfilled _Performance class also now prefers globalThis.performance.now if available (and timeOrigin of instance is unchanged or 0 in worked)

Credits to @IgorMinar for ideas in https://github.com/unjs/unenv/pull/209#issuecomment-2130393653 by