diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 584ca6ba7b178..6b98d608cfcab 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -55,7 +55,8 @@ "theNodejsEventLoop": "The Node.js Event Loop", "theNodejsEventEmitter": "The Node.js Event Emitter", "understandingProcessnexttick": "Understanding process.nextTick()", - "understandingSetimmediate": "Understanding setImmediate()" + "understandingSetimmediate": "Understanding setImmediate()", + "dontBlockTheEventLoop": "Don't Block the Event Loop" } }, "manipulatingFiles": { diff --git a/navigation.json b/navigation.json index 211f36f8e7b65..eb51aa6015145 100644 --- a/navigation.json +++ b/navigation.json @@ -169,6 +169,10 @@ "understandingSetimmediate": { "link": "/learn/asynchronous-work/understanding-setimmediate", "label": "components.navigation.learn.asynchronousWork.links.understandingSetimmediate" + }, + "dontBlockTheEventLoop": { + "link": "/learn/asynchronous-work/dont-block-the-event-loop", + "label": "components.navigation.learn.asynchronousWork.links.dontBlockTheEventLoop" } } }, diff --git a/pages/en/guides/index.md b/pages/en/guides/index.md deleted file mode 100644 index 6e8879a9d44bd..0000000000000 --- a/pages/en/guides/index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: Guides -layout: docs.hbs ---- - -# Node.js Guides - -> Note: The Node.js Guides are being archived and incrementally being replaced by the "Learn" section of the Node.js Website. These Guides will remain available at this location until the transition is complete. - -## Node.js core concepts - -- [Don't Block the Event Loop (or the Worker Pool)](/guides/dont-block-the-event-loop/) diff --git a/pages/en/guides/dont-block-the-event-loop.md b/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md similarity index 99% rename from pages/en/guides/dont-block-the-event-loop.md rename to pages/en/learn/asynchronous-work/dont-block-the-event-loop.md index 3dad725c4974a..79442f92abc2d 100644 --- a/pages/en/guides/dont-block-the-event-loop.md +++ b/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md @@ -1,6 +1,6 @@ --- title: Don't Block the Event Loop (or the Worker Pool) -layout: docs.hbs +layout: learn.hbs --- # Don't Block the Event Loop (or the Worker Pool) @@ -270,12 +270,12 @@ If your server manipulates JSON objects, particularly those from a client, you s Example: JSON blocking. We create an object `obj` of size 2^21 and `JSON.stringify` it, run `indexOf` on the string, and then JSON.parse it. The `JSON.stringify`'d string is 50MB. It takes 0.7 seconds to stringify the object, 0.03 seconds to indexOf on the 50MB string, and 1.3 seconds to parse the string. ```js -var obj = { a: 1 }; -var niter = 20; +let obj = { a: 1 }; +let niter = 20; -var before, str, pos, res, took; +let before, str, pos, res, took; -for (var i = 0; i < niter; i++) { +for (let i = 0; i < niter; i++) { obj = { obj1: obj, obj2: obj }; // Doubles in size each iter } @@ -325,7 +325,7 @@ Example 2: Partitioned average, each of the `n` asynchronous steps costs `O(1)`. ```js function asyncAvg(n, avgCB) { // Save ongoing sum in JS closure. - var sum = 0; + let sum = 0; function help(i, cb) { sum += i; if (i == n) { @@ -340,7 +340,7 @@ function asyncAvg(n, avgCB) { // Start the helper, with CB to call avgCB. help(1, function (sum) { - var avg = sum / n; + let avg = sum / n; avgCB(avg); }); } diff --git a/redirects.json b/redirects.json index 0b0cc92124b51..d80d9d300bae1 100644 --- a/redirects.json +++ b/redirects.json @@ -240,6 +240,10 @@ "source": "/:locale/guides/event-loop-timers-and-nexttick", "destination": "/:locale/learn/asynchronous-work/event-loop-timers-and-nexttick" }, + { + "source": "/:locale/guides/dont-block-the-event-loop", + "destination": "/:locale/learn/asynchronous-work/dont-block-the-event-loop" + }, { "source": "/:locale/get-involved", "destination": "/:locale/about/get-involved"