-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #69
- Loading branch information
Showing
7 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Deferring by tick | ||
|
||
[Timers](https://nodejs.org/en/docs/guides/timers-in-node/) are functions for executing code after a set period of time. | ||
|
||
Due to historical reasons, the way you interact with timers functions depend of on where you are running the code. | ||
|
||
Although they are used in a homogeneous way, these functions work slightly different between them in terms of performance: | ||
|
||
- [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) is the most generic, but a bit slow because its clamped to 4ms. | ||
- [setImmediate](https://nodejs.org/api/timers.html#timers_setimmediate_callback_args) is not available in most places (and probably never will be). | ||
- [process.nextTick](https://nodejs.org/api/process.html#process_process_nexttick_callback_args) is only in Node.js. | ||
- [Promise#then](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) needs polyfills in places. | ||
|
||
A simple and tiny library to ensure to use the fastest timer function available is [tickedoff](https://github.com/jamiebuilds/tickedoff). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters