From f00cef55aaeacd97c0bf1e445b8189836440b223 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:16:56 +0300 Subject: [PATCH 1/8] doc: replace `var` by `const` in modules.md --- doc/api/modules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 397964c2511aed..cddc71a66d8fdf 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -44,7 +44,7 @@ Below, `bar.js` makes use of the `square` module, which exports a constructor: ```js const square = require('./square.js'); -var mySquare = square(2); +const mySquare = square(2); console.log(`The area of my square is ${mySquare.area()}`); ``` @@ -566,7 +566,7 @@ To illustrate the behavior, imagine this hypothetical implementation of ```js function require(...) { - var module = { exports: {} }; + const module = { exports: {} }; ((module, exports) => { // Your module code here. In this example, define a function. function some_func() {}; From 61c10a34adce8d65ab77948235dd1e86bde12461 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:18:38 +0300 Subject: [PATCH 2/8] doc: fix semicolons in modules.md --- doc/api/modules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index cddc71a66d8fdf..fb26a1790bf5fd 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -56,7 +56,7 @@ module.exports = (width) => { return { area: () => width * width }; -} +}; ``` The module system is implemented in the `require("module")` module. @@ -569,7 +569,7 @@ function require(...) { const module = { exports: {} }; ((module, exports) => { // Your module code here. In this example, define a function. - function some_func() {}; + function some_func() {} exports = some_func; // At this point, exports is no longer a shortcut to module.exports, and // this module will still export an empty default object. From 060b7870913e1c5170d22b44bc8f9302aac0ab26 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:20:47 +0300 Subject: [PATCH 3/8] doc: add missing code marks in modules.md --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index fb26a1790bf5fd..ba13e357a5a135 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -142,7 +142,7 @@ To get the exact filename that will be loaded when `require()` is called, use the `require.resolve()` function. Putting together all of the above, here is the high-level algorithm -in pseudocode of what require.resolve does: +in pseudocode of what `require.resolve()` does: ```txt require(X) from module at path Y From 9dd718341a3b5fd1eba516418beb61fd6f7d47cb Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:21:46 +0300 Subject: [PATCH 4/8] doc: unify quotes in modules.md --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index ba13e357a5a135..4fa93d21525172 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -59,7 +59,7 @@ module.exports = (width) => { }; ``` -The module system is implemented in the `require("module")` module. +The module system is implemented in the `require('module')` module. ## Accessing the main module From 7848aef90683b419e1c7eecb8fbc2b89b76822ca Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:23:12 +0300 Subject: [PATCH 5/8] doc: comment out ellipsis in modules.md --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 4fa93d21525172..abc53a970a511c 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -565,7 +565,7 @@ To illustrate the behavior, imagine this hypothetical implementation of `require()`, which is quite similar to what is actually done by `require()`: ```js -function require(...) { +function require(/* ... */) { const module = { exports: {} }; ((module, exports) => { // Your module code here. In this example, define a function. From e1f89971a27b4c53b6a114e344de2d1b99c5420d Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:24:10 +0300 Subject: [PATCH 6/8] doc: use object destructuring in modules.md --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index abc53a970a511c..400f3b42fddd09 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -20,7 +20,7 @@ directory as `foo.js`. Here are the contents of `circle.js`: ```js -const PI = Math.PI; +const { PI } = Math; exports.area = (r) => PI * r * r; From 659a802368150f1d2d55c3aa745e0405b6c07d77 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 5 Apr 2017 04:31:58 +0300 Subject: [PATCH 7/8] doc: use exponentiation operator in modules.md --- doc/api/modules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 400f3b42fddd09..93ddbc3fe83f28 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -22,7 +22,7 @@ Here are the contents of `circle.js`: ```js const { PI } = Math; -exports.area = (r) => PI * r * r; +exports.area = (r) => PI * r ** 2; exports.circumference = (r) => 2 * PI * r; ``` @@ -54,7 +54,7 @@ The `square` module is defined in `square.js`: // assigning to exports will not modify module, must use module.exports module.exports = (width) => { return { - area: () => width * width + area: () => width ** 2 }; }; ``` From caf094f19939a55d235c508d69c983bd16ae9af0 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 7 Apr 2017 22:42:14 +0300 Subject: [PATCH 8/8] doc: replace snake_case by camelCase in modules.md --- doc/api/modules.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 93ddbc3fe83f28..65f57314ccd9f2 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -569,12 +569,12 @@ function require(/* ... */) { const module = { exports: {} }; ((module, exports) => { // Your module code here. In this example, define a function. - function some_func() {} - exports = some_func; + function someFunc() {} + exports = someFunc; // At this point, exports is no longer a shortcut to module.exports, and // this module will still export an empty default object. - module.exports = some_func; - // At this point, the module will now export some_func, instead of the + module.exports = someFunc; + // At this point, the module will now export someFunc, instead of the // default object. })(module, module.exports); return module.exports;