node.fs
File I/O is tricky because there are not simple non-blocking ways to do it.
Node handles file I/O by employing Node has a simple module loading system. In Node, files and modules are
in one-to-one correspondence.
-
- As an example,
+As an example,
The contents of Here the module The module Because file loading does not happen instantaneously, and because Node
has a policy of never blocking, the callback To export an object, add to the special The functions Purely evented I/O for V8 javascript.
- This is an example of a web server written with Node which responds with
+ An example of a web server written with Node which responds with
"Hello World" after waiting two seconds:
- To run the server, put the code into a file To run the server, put the code into a file See the API documentation for more examples.
+ See the API documentation for more examples.
Node is released under an MIT license. Node aims to support all POSIX operating systems (including
-Windows with mingw). However at the moment it is only being tested on
-Macintosh and Linux.
+Windows with mingw) but at the moment it is only being tested on
+Linux, Macintosh, and FreeBSD.
+The build system requires Python.
+V8, on which Node is built, supports only IA-32 and ARM processors.
- V8, on which Node is built, supports only IA-32 and ARM processors.
-
- The build system requires Python.
-
- To run the unit tests
+foo.js
loads the module mjsunit.js
.
foo.js
:
@@ -730,7 +729,7 @@ exports.assertEquals = function (expected, found, name_opt) {
};
-mjsunit.js
has exported the function
+mjsunit
has exported a function
assertEquals()
. mjsunit.js
must be in the
same directory as foo.js
for include()
to find it.
The module path is relative to the file calling include()
.
@@ -742,12 +741,11 @@ from the specified module into the global namespace.
onLoad
can be set and will notify the user
-when all the included modules are loaded. Each file/module can have an onLoad
callback.
exports
object.
-
-fail
and deepEquals
are not
+The functions fail
and deepEquals
are not
exported and remain private to the module.
require()
is like include()
except does not
diff --git a/website/index.html b/website/index.html
index cddf99c65f..30a922f7fe 100644
--- a/website/index.html
+++ b/website/index.html
@@ -17,26 +17,28 @@
new node.http.Server(function (req, res) {
+
-
+new node.http.Server(function (req, res) {
setTimeout(function () {
res.sendHeader(200, [["Content-Type", "text/plain"]]);
res.sendBody("Hello World");
res.finish();
}, 2000);
}).listen(8000);
-puts("Server running at http://127.0.0.1:8000/");
+puts("Server running at http://127.0.0.1:8000/");
+server.js
+example.js
and execute it with the node
program
-% /usr/local/bin/node server.js
+
% /usr/local/bin/node example.js
Server running at http://127.0.0.1:8000/
-Build
./configure
+
+
+./configure
make
-make install
+make install
+
+./configure --debug
+make test
+