Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use global.performance instead of perf_hooks.performance for Node >16 #93

Open
kevinyou opened this issue Jan 17, 2023 · 0 comments
Open

Comments

@kevinyou
Copy link

kevinyou commented Jan 17, 2023

Currently, this library uses the just-performance polyfill to get current time: https://github.com/jhurliman/node-rate-limiter/blob/25a866d/src/clock.ts

And that polyfill loads performance from perf_hooks: https://github.com/jhurliman/just-performance/blob/main/src/node.ts

As of node v16, performance is directly exposed under global.performance - nodejs/node#37970

One benefit of this change is that popular library @sinonjs/fake-timers only overrides the global performance object, and not perf_hooks.performance. So right now, users of this library need to explicitly mock out perf_hooks.performance (or just-performance.performance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant