Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: document auto-loading #992

Closed
leofiore opened this issue Feb 27, 2015 · 6 comments
Closed

repl: document auto-loading #992

leofiore opened this issue Feb 27, 2015 · 6 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@leofiore
Copy link

this is my first attempt to io.js . I Installed version 1.3 on my mac, osx yosemite, via macports. I looked for documentation at https://iojs.org/api/ to use fs module. reading at fs documentation the first statement is

Use require('fs') to access this module. 

The same statement is repeated on every module but, trying to use the CLI shell, i noticed several modules (probably all) are already loaded

~ leonardo$ iojs
>
...
cluster                       console
crypto                        dgram
dns                           domain
escape                        events
fs                            global
http                          https
module                        net
os                            path
process                       punycode
querystring                   readline
require                       root
setImmediate                  setInterval
setTimeout                    smalloc
stream                        string_decoder
tls                           tty
unescape                      url
util                          v8
vm                            zlib
...

> cfs = require('fs')
> fs == cfs
true

so, if my guess is correct, the documentation should be updated to reflect the fact that require actually is not required for the standard module if using the CLI shell.

@piscisaureus
Copy link
Contributor

The same statement is repeated on every module but, trying to use the console, i noticed several modules (probably all) are already loaded

That's not entirely true. The REPL auto-loads modules but if you're running a script from a file you actually have to require() these modules to use them.

@leofiore
Copy link
Author

That's not entirely. The REPL auto-loads modules but if you're running a script from a file you actually > have to require() these modules to use them.

Right, i corrected my report to highlight that i was using the shell.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 27, 2015

If anything, a sentence could be added to the REPL docs.

@benjamingr
Copy link
Member

+1 on the REPL docs suggestion.

@mscdex mscdex added the doc Issues and PRs related to the documentations. label Mar 9, 2015
@silverwind
Copy link
Contributor

It's more like on-demand loading, isn't it?

> Object.keys(global).indexOf("fs")
-1
> fs; Object.keys(global).indexOf("fs")
21

@silverwind silverwind changed the title Update documentation for already loaded modules repl: document auto-loading Mar 24, 2015
silverwind added a commit that referenced this issue Mar 24, 2015
Fixes: #992
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
PR-URL: #1249
@silverwind
Copy link
Contributor

documented that feature in e84dd5f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests

6 participants