diff options
author | Ryan Graham <r.m.graham@gmail.com> | 2013-04-08 09:59:58 -0700 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-05-15 21:06:32 +0200 |
commit | 1deeab29f27ec5d11cb851e18449cfa2d634c7f5 (patch) | |
tree | 22e336e95296b4495b3353fca28df525c265591e | |
parent | 93391ae9cb162dc79d3307b0e7767f5f505a5c69 (diff) | |
download | node-1deeab29f27ec5d11cb851e18449cfa2d634c7f5.tar.gz |
doc: improve exports/module.exports consistency
While they reference the same object, they are only interchangeable
for updates, not assignment.
-rw-r--r-- | doc/api/modules.markdown | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/api/modules.markdown b/doc/api/modules.markdown index 95e301265..c551cb010 100644 --- a/doc/api/modules.markdown +++ b/doc/api/modules.markdown @@ -87,7 +87,7 @@ Consider this situation: When `main.js` loads `a.js`, then `a.js` in turn loads `b.js`. At that point, `b.js` tries to load `a.js`. In order to prevent an infinite loop an **unfinished copy** of the `a.js` exports object is returned to the -`b.js` module. `b.js` then finishes loading, and its exports object is +`b.js` module. `b.js` then finishes loading, and its `exports` object is provided to the `a.js` module. By the time `main.js` has loaded both modules, they're both finished. @@ -240,7 +240,7 @@ representing the current module. In particular * {Object} -The `exports` object is created by the Module system. Sometimes this is not +The `module.exports` object is created by the Module system. Sometimes this is not acceptable, many want their module to be an instance of some class. To do this assign the desired export object to `module.exports`. For example suppose we were making a module called `a.js` @@ -281,13 +281,13 @@ y.js: ### module.require(id) * `id` {String} -* Return: {Object} `exports` from the resolved module +* Return: {Object} `module.exports` from the resolved module The `module.require` method provides a way to load a module as if `require()` was called from the original module. Note that in order to do this, you must get a reference to the `module` -object. Since `require()` returns the `exports`, and the `module` is +object. Since `require()` returns the `module.exports`, and the `module` is typically *only* available within a specific module's code, it must be explicitly exported in order to be used. |