From f3af6c6f531e5dbef144e2aa1f0ed2c3db75455a Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 25 May 2009 19:52:05 +0200 Subject: [PATCH] More docs --- website/node.html | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/website/node.html b/website/node.html index e64b593443..a11115ae47 100644 --- a/website/node.html +++ b/website/node.html @@ -112,8 +112,14 @@ a:hover { text-decoration: underline; }

Node

-

Purely asynchronous I/O for Purely asynchronous server-side I/O for V8 javascript. + +

Analogy +

+Python     : Twisted
+Ruby       : Event Machine
+Javascript : Node

This is an example of a web server written with Node which responds with "Hello World" after waiting two seconds: @@ -127,13 +133,6 @@ a:hover { text-decoration: underline; } }).listen(8000); puts("Server running at http://127.0.0.1:8000/"); -

-Node is an evented sandbox where users cannot execute blocking I/O. -This is -already natural for Javascript programmers, as the DOM is almost entirely -asynchronous. The goal is a framework to easily create -efficient network applications. -

See the API documentation for more examples. @@ -164,6 +163,14 @@ make install on. All methods and members are camel cased. Constructors always have a capital first letter. +

Node uses strings to represent ASCII or UTF-8 encoded data. For the +moment, arrays of integers are used to represent raw binary data—this +representation is rather inefficient. In the future, when V8 natively supports binary +Blob objects, Node will use them. + +

The following are some global general purpose functions:

+
puts(string, callback)
@@ -255,9 +262,9 @@ completion callbacks: var path = "/some/path/that/doesnt/exist"; var file = new node.fs.File(); file.onError = function (method, errno, msg) { - stderr.puts("An error occurred calling " + method + " on " + path); + stderr.puts("An error occurred calling " + method); stderr.puts(msg); - exit(1); + node.exit(1); } file.open(path, "w+") @@ -314,10 +321,11 @@ file.open(path, "w+")

node.http

-

Node provides a web server and client interface. The interface is rather -low-level but complete (it does not limit you from -any of HTTP's features). The interface abstracts the transfer-encoding (i.e. -chunked or identity), message boundaries, and persistent connections. +

The HTTP interfaces here are designed to support many features +of the protocol which have been traditionally difficult to handle. In +particular, large, possibly chunked, messages. The interface is +careful to never buffer entire requests or responses—the user is able +to stream data.

HTTP message headers are represented by an array of 2-element arrays like this