Skip to content

Commit 159abe0

Browse files
authored
Merge pull request #4229 from kevin8999/patch-6
docs(part4a): Clarify explanation of exporting and importing multiple modules
2 parents 9962f53 + 139870f commit 159abe0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/content/4/en/part4a.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ info('message')
363363
error('error message')
364364
```
365365
366-
The second way of exporting may be preferable if only a small portion of the exported functions are used in a file. E.g. in file <i>controller/notes.js</i> exporting happens as follows:
366+
The second way of exporting may be preferable if only a small portion of the exported functions are used in a file.
367+
368+
However, in some cases, only one "thing" is exported. For example, <i>controller/notes.js</i> exports one "thing" like so:
367369
368370
```js
369371
const notesRouter = require('express').Router()
@@ -374,7 +376,7 @@ const Note = require('../models/note')
374376
module.exports = notesRouter // highlight-line
375377
```
376378
377-
In this case, there is just one "thing" exported, so the only way to use it is the following:
379+
Because only one "thing" is exported, it can only be imported and used as one object:
378380
379381
```js
380382
const notesRouter = require('./controllers/notes')
@@ -384,7 +386,7 @@ const notesRouter = require('./controllers/notes')
384386
app.use('/api/notes', notesRouter)
385387
```
386388
387-
Now the exported "thing" (in this case a router object) is assigned to a variable and used as such.
389+
Now, the exported "thing" (in this case, a router object) is assigned to a variable _notesRouter_ and is used as a single object.
388390
389391
#### Finding the usages of your exports with VS Code
390392

0 commit comments

Comments
 (0)