Skip to content

Commit

Permalink
Add deferring section
Browse files Browse the repository at this point in the history
Closes #69
  • Loading branch information
Kikobeats committed Mar 26, 2018
1 parent 6666a4a commit 15ee83a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* [Freeing memory](v8-tips/freeing-memory.md)

* Workflow
* [Deferring by a tick](workflow/defer.md)
* [Lookup table](workflow/lookup-table.md)
* [Math methods](workflow/math.md)
* [Memoization](workflow/memoization.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

## General

* [steed](https://github.com/mcollina/steed)Horsepower for your modules.
* [reusify](https://github.com/mcollina/reusify)Reuse objects and functions with style.
* [tickedoff](https://github.com/jamiebuilds/tickedoff)Use the faster timer function available for deferring something by a "tick".
* [sliced](https://www.npmjs.com/package/sliced)A faster Node.js alternative to `Array.prototype.slice.call(arguments)`.

## Cache

* [lru](https://github.com/chriso/lru) – A simple LRU cache supporting O(1) set, get and eviction of old keys.
* [async-lru](https://github.com/feross/async-lru) – Like LRU but for async calls.
* [lru](https://github.com/chriso/lru) – A simple LRU cache supporting O(1) set, get and eviction of old keys.
* [mem](https://github.com/sindresorhus/mem) - An optimization used to speed up consecutive function calls.
* [memo-async-lru](https://github.com/feross/memo-async-lru) – Memoize Node.js style callback-last functions, using an in-memory LRU store.

## Benchmark

* [bhdr](https://github.com/mcollina/bhdr) – Benchmark utility powered by hdr histograms.
* [fastbench](https://www.npmjs.com/package/fastbench) – The simplest benchmark you can run on node.
* [nanobench](https://github.com/mafintosh/nanobench) – Simple benchmarking tool with TAP-like output that is easy to parse.
* [bhdr](https://github.com/mcollina/bhdr) – Benchmark utility powered by hdr histograms.

## Debugging

* [0x](https://www.npmjs.com/package/0x) – Visualize stack traces.

## Array

* [array-list](https://github.com/Kikobeats/array-list#array-list) – Simple array list implementation.
* [sliced](https://www.npmjs.com/package/sliced) – A faster Node.js alternative to `Array.prototype.slice.call(arguments)`.
2 changes: 1 addition & 1 deletion docs/style.min.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/workflow/defer.md
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).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"devDependencies": {
"concurrently": "latest",
"docsify-cli": "latest",
"docsify-cli": "~4.2.1",
"gulp": "latest",
"gulp-autoprefixer": "latest",
"gulp-concat": "latest",
Expand Down
1 change: 1 addition & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ main {
body.sticky .sidebar,
body.sticky .sidebar-toggle {
position: fixed;
cursor: pointer;
}

.content {
Expand Down

0 comments on commit 15ee83a

Please sign in to comment.