-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
suggestion timer shouldn't require nodejs #1704
Comments
Thank you. I had not realized you were using it. Is there a way for me to try out any fixes? |
Here is a stackblitz that is relatively close to a working example. Stackblitz automatically polyfills process and hrtime, so it's not a perfect example. In a non-polyfilled environment, the entire process variable would be undefined. Thanks! |
How are you running it in the browser? Is it Webpacked first? or something else? I'm trying to get a feel for what type of polyfill will work. |
I took a look at the code and see that I had not "imported" |
* Have a backup timer Related to #1704
I have added the changes. Please try out |
I think that is an improvement because now the code breaks at compile time instead of only when it's called in the browser.
Looking at https://github.com/eyas-ranjous/timer-node/blob/master/src/timer.js , it seems like they use Date.now(). That works natively in the browser and in nodejs, and it returns the number of milliseconds since 1970. It doesn't have as much resolution as hrtime (which has nanoseconds), but that probably doesn't matter for this context because the timeout is measured in milliseconds and would probably never be set to a value < 10 milliseconds. Thanks! |
Cool. The error makes sense. There is an easy fix on my side. |
* fix: Use process directly instead of importing it. Fix: #1704
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
Hi. We use cspell-trie-lib in the browser for checking spelling and suggesting alternatives. Until very recently, that worked extremely well. After we upgraded (I think to 5.9.0), suggestions stopped working and would instead throw this error (only in the browser).
Describe the solution you'd like
It would be nice to either be able to conditionally disable the timer, or if the timer used a time source that would work in both the browser and nodejs. I'm not sure exactly what that would entail.
Describe alternatives you've considered
It is possible to polyfill that specific node api using https://www.npmjs.com/package/browser-process-hrtime
Additional context
Thanks!
The text was updated successfully, but these errors were encountered: