Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

'make doc' passing. Still needs more cleanup

  • Loading branch information...
commit b88cc7f20bfb4761e16871bcf2e4d6de4c16e23b 1 parent 20ba857
@isaacs isaacs authored
View
109 doc/api/child_processes.markdown
@@ -24,8 +24,8 @@ The ChildProcess class is not intended to be used directly. Use the
### Event: 'exit'
-* `code` Number, the exit code, if it exited normally.
-* `signal` String, the signal passed to kill the child process, if it
+* `code` {Number} the exit code, if it exited normally.
+* `signal` {String} the signal passed to kill the child process, if it
was killed by the parent.
This event is emitted after the child process ends. If the process terminated
@@ -44,7 +44,7 @@ An alternative way to check if you can send messages is to see if the
### child.stdin
-* Stream object
+* {Stream object}
A `Writable Stream` that represents the child process's `stdin`.
Closing this stream via `end()` often causes the child process to terminate.
@@ -54,7 +54,7 @@ not be set.
### child.stdout
-* Stream object
+* {Stream object}
A `Readable Stream` that represents the child process's `stdout`.
@@ -63,7 +63,7 @@ not be set.
### child.stderr
-* Stream object
+* {Stream object}
A `Readable Stream` that represents the child process's `stderr`.
@@ -72,7 +72,7 @@ not be set.
### child.pid
-* Integer
+* {Integer}
The PID of the child process.
@@ -86,7 +86,7 @@ Example:
### child.kill([signal])
-* `signal` String
+* `signal` {String}
Send a signal to the child process. If no argument is given, the process will
be sent `'SIGTERM'`. See `signal(7)` for a list of available signals.
@@ -108,8 +108,8 @@ See `kill(2)`
### child.send(message, [sendHandle])
-* `message` Object
-* `sendHandle` Handle object, Optional
+* `message` {Object}
+* `sendHandle` {Handle object}
Send a message (and, optionally, a handle object) to a child process.
@@ -117,15 +117,15 @@ See `child_process.fork()` for details.
## child_process.spawn(command, [args], [options])
-* `command` String - The command to run
-* `args` Array - List of string arguments, Optional
-* `options` Object, Optional
- * `cwd` String - Current working directory of the child process
- * `customFds` - **Deprecated** File descriptors for the child to use
+* `command` {String} The command to run
+* `args` {Array} List of string arguments
+* `options` {Object}
+ * `cwd` {String} Current working directory of the child process
+ * `customFds` {Array} **Deprecated** File descriptors for the child to use
for stdio. (See below)
- * `env` Object - Environment key-value pairs
- * `setsid` Boolean
-* Return: ChildProcess object
+ * `env` {Object} Environment key-value pairs
+ * `setsid` {Boolean}
+* return: {ChildProcess object}
Launches a new process with the given `command`, with command line arguments in `args`.
If omitted, `args` defaults to an empty Array.
@@ -230,18 +230,21 @@ See also: `child_process.exec()` and `child_process.fork()`
## child_process.exec(command, [options], callback)
-* `command` String - The command to run, with space-separated arguments
-* `options` Object, Optional
- * `cwd` String - Current working directory of the child process
- * `customFds` - **Deprecated** File descriptors for the child to use
+* `command` {String} The command to run, with space-separated arguments
+* `options` {Object}
+ * `cwd` {String} Current working directory of the child process
+ * `customFds` {Array} **Deprecated** File descriptors for the child to use
for stdio. (See below)
- * `env` Object - Environment key-value pairs
- * `setsid` Boolean
- * `encoding` String, Default: 'utf8'
- * `timeout` Number, Default: 0
- * `maxBuffer` Number, Default: 200*1024
- * `killSignal` String, Default: 'SIGTERM'
-* `callback` Function called with the output when process terminates
+ * `env` {Object} Environment key-value pairs
+ * `setsid` {Boolean}
+ * `encoding` {String} (Default: 'utf8')
+ * `timeout` {Number} (Default: 0)
+ * `maxBuffer` {Number} (Default: 200*1024)
+ * `killSignal` {String} (Default: 'SIGTERM')
+* `callback` {Function} called with the output when process terminates
+ * `code` {Integer} Exit code
+ * `stdout` {Buffer}
+ * `stderr` {Buffer}
* Return: ChildProcess object
Runs a command in a shell and buffers the output.
@@ -283,18 +286,22 @@ the child process is killed.
## child_process.execFile(file, args, options, callback)
-* `command` String - The command to run, with space-separated arguments
-* `options` Object, Optional
- * `cwd` String - Current working directory of the child process
- * `customFds` - **Deprecated** File descriptors for the child to use
+* `file` {String} The filename of the program to run
+* `args` {Array} List of string arguments
+* `options` {Object}
+ * `cwd` {String} Current working directory of the child process
+ * `customFds` {Array} **Deprecated** File descriptors for the child to use
for stdio. (See below)
- * `env` Object - Environment key-value pairs
- * `setsid` Boolean
- * `encoding` String, Default: 'utf8'
- * `timeout` Number, Default: 0
- * `maxBuffer` Number, Default: 200*1024
- * `killSignal` String, Default: 'SIGTERM'
-* `callback` Function called with the output when process terminates
+ * `env` {Object} Environment key-value pairs
+ * `setsid` {Boolean}
+ * `encoding` {String} (Default: 'utf8')
+ * `timeout` {Number} (Default: 0)
+ * `maxBuffer` {Number} (Default: 200*1024)
+ * `killSignal` {String} (Default: 'SIGTERM')
+* `callback` {Function} called with the output when process terminates
+ * `code` {Integer} Exit code
+ * `stdout` {Buffer}
+ * `stderr` {Buffer}
* Return: ChildProcess object
This is similar to `child_process.exec()` except it does not execute a
@@ -302,18 +309,22 @@ subshell but rather the specified file directly. This makes it slightly
leaner than `child_process.exec`. It has the same options.
-## child_process.fork(modulePath, [arguments], [options])
+## child_process.fork(modulePath, [args], [options])
-* `command` String - The command to run, with space-separated arguments
-* `options` Object, Optional
- * `cwd` String - Current working directory of the child process
- * `customFds` - **Deprecated** File descriptors for the child to use
+* `modulePath` {String} The module to run in the child
+* `args` {Array} List of string arguments
+* `options` {Object}
+ * `cwd` {String} Current working directory of the child process
+ * `customFds` {Array} **Deprecated** File descriptors for the child to use
for stdio. (See below)
- * `env` Object - Environment key-value pairs
- * `setsid` Boolean
- * `silent` Boolean, If true, child doesn't write to parent's stdout
- and stderr.
-* `callback` Function called with the output when process terminates
+ * `env` {Object} Environment key-value pairs
+ * `setsid` {Boolean}
+ * `encoding` {String} (Default: 'utf8')
+ * `timeout` {Number} (Default: 0)
+* `callback` {Function} called with the output when process terminates
+ * `code` {Integer} Exit code
+ * `stdout` {Buffer}
+ * `stderr` {Buffer}
* Return: ChildProcess object
This is a special case of the `spawn()` functionality for spawning Node
View
86 doc/api/cluster.markdown
@@ -43,19 +43,19 @@ Please try it out and provide feedback.
## cluster.settings
-* Object
- * exec: String, file path to worker file. Default: `__filename`
- * args: Array, string arguments passed to worker.
- Default: `process.argv.slice(2)`
- * silent: Boolean, whether or not to send output to parent's stdio.
- Default: `false`
+* {Object}
+ * `exec` {String} file path to worker file. (Default=`__filename`)
+ * `args` {Array} string arguments passed to worker.
+ (Default=`process.argv.slice(2)`)
+ * `silent` {Boolean} whether or not to send output to parent's stdio.
+ (Default=`false`)
All settings set by the `.setupMaster` is stored in this settings object.
This object is not supposed to be change or set manually, by you.
## cluster.isMaster
-* Boolean
+* {Boolean}
True if the process is a master. This is determined
by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID` is
@@ -63,7 +63,7 @@ undefined, then `isMaster` is `true`.
## cluster.isWorker
-* Boolean
+* {Boolean}
This boolean flag is true if the process is a worker forked from a master.
If the `process.env.NODE_UNIQUE_ID` is set to a value, then
@@ -71,7 +71,7 @@ If the `process.env.NODE_UNIQUE_ID` is set to a value, then
## Event: 'fork'
-* Argument: `worker` object
+* `worker` {Worker object}
When a new worker is forked the cluster module will emit a 'fork' event.
This can be used to log worker activity, and create you own timeout.
@@ -94,7 +94,7 @@ This can be used to log worker activity, and create you own timeout.
## Event: 'online'
-* Argument: `worker` object
+* `worker` {Worker object}
After forking a new worker, the worker should respond with a online message.
When the master receives a online message it will emit such event.
@@ -108,7 +108,7 @@ being executed.
## Event: 'listening'
-* Argument: `worker` object
+* `worker` {Worker object}
When calling `listen()` from a worker, a 'listening' event is automatically assigned
to the server instance. When the server is listening a message is send to the master
@@ -120,7 +120,7 @@ where the 'listening' event is emitted.
## Event: 'death'
-* Argument: `worker` object
+* `worker` {Worker object}
When any of the workers die the cluster module will emit the 'death' event.
This can be used to restart the worker by calling `fork()` again.
@@ -130,9 +130,9 @@ This can be used to restart the worker by calling `fork()` again.
cluster.fork();
});
-## Event 'setup'
+## Event: 'setup'
-* Argument: `worker` object
+* `worker` {Worker object}
When the `.setupMaster()` function has been executed this event emits.
If `.setupMaster()` was not executed before `fork()` this function will
@@ -140,12 +140,12 @@ call `.setupMaster()` with no arguments.
## cluster.setupMaster([settings])
-* `settings` Object, Optional
- * exec: String, file path to worker file. Default: `__filename`
- * args: Array, string arguments passed to worker.
- Default: `process.argv.slice(2)`
- * silent: Boolean, whether or not to send output to parent's stdio.
- Default: `false`
+* `settings` {Object}
+ * `exec` {String} file path to worker file. (Default=`__filename`)
+ * `args` {Array} string arguments passed to worker.
+ (Default=`process.argv.slice(2)`)
+ * `silent` {Boolean} whether or not to send output to parent's stdio.
+ (Default=`false`)
The `setupMaster` is used to change the default 'fork' behavior. It takes
one option object argument.
@@ -162,27 +162,26 @@ Example:
## cluster.fork([env])
-* `env` Object, Optional. Key/value pairs to add to child process
- environment.
-* Return: Worker Object
+* `env` {Object} Key/value pairs to add to child process environment.
+* return {Worker object}
Spawn a new worker process. This can only be called from the master process.
## cluster.settings
-* Object
- * exec: String, file path to worker file. Default: `__filename`
- * args: Array, string arguments passed to worker.
- Default: `process.argv.slice(2)`
- * silent: Boolean, whether or not to send output to parent's stdio.
- Default: `false`
+* {Object}
+ * `exec` {String} file path to worker file. Default: `__filename`
+ * `args` {Array} string arguments passed to worker.
+ (Default=`process.argv.slice(2)`)
+ * `silent` {Boolean} whether or not to send output to parent's stdio.
+ (Default=`false`)
All settings set by the `.setupMaster` is stored in this settings object.
-This object is not supposed to be change or set manually, by you.
+This object is not supposed to be change or set manually.
## cluster.workers
-* Object
+* {Object}
In the cluster all living worker objects are stored in this object by there
`uniqueID` as the key. This makes it easy to loop through all living workers.
@@ -212,21 +211,26 @@ it can be obtained using `cluster.worker`.
### worker.uniqueID
-* String
+* {String}
Each new worker is given its own unique id, this id is stored in the
`uniqueID`.
+While a worker is alive, this is the key that indexes it in
+cluster.workers
+
### worker.process
-* ChildProcess object
+* {ChildProcess object}
-All workers are created using `child_process.fork()`, the returned objecto
+All workers are created using `child_process.fork()`, the returned object
from this function is stored in process.
+See: [Child Process module](child_process.html)
+
### worker.suicide
-* Boolean
+* {Boolean}
This property is a boolean. It is set when a worker dies, until then it is
`undefined`. It is true if the worker was killed using the `.destroy()`
@@ -234,8 +238,8 @@ method, and false otherwise.
### worker.send(message, [sendHandle])
-* `message` Object
-* `sendHandle` Handle object, Optional
+* `message` {Object}
+* `sendHandle` {Handle object}
This function is equal to the send methods provided by
`child_process.fork()`. In the master you should use this function to
@@ -271,7 +275,7 @@ a suicide boolean is set to true.
### Event: 'message'
-* Argument: `message` Object
+* `message` {Object}
This event is the same as the one provided by `child_process.fork()`.
In the master you should use this event, however in a worker you can also use
@@ -318,7 +322,7 @@ in the master process using the message system:
### Event: 'online'
-* Argument: `worker` Worker object
+* `worker` {Worker object}
Same as the `cluster.on('online')` event, but emits only when the state change
on the specified worker.
@@ -329,7 +333,7 @@ on the specified worker.
### Event: 'listening'
-* Argument: `worker` Worker object
+* `worker` {Worker object}
Same as the `cluster.on('listening')` event, but emits only when the state change
on the specified worker.
@@ -340,7 +344,7 @@ on the specified worker.
### Event: 'death'
-* Argument: `worker` Worker object
+* `worker` {Worker object}
Same as the `cluster.on('death')` event, but emits only when the state change
on the specified worker.
View
22 doc/api/dns.markdown
@@ -1,4 +1,4 @@
-## DNS
+# DNS
Use `require('dns')` to access this module. All methods in the dns module
use C-Ares except for `dns.lookup` which uses `getaddrinfo(3)` in a thread
@@ -31,7 +31,7 @@ resolves the IP addresses which are returned.
});
});
-### dns.lookup(domain, [family], callback)
+## dns.lookup(domain, [family], callback)
Resolves a domain (e.g. `'google.com'`) into the first found A (IPv4) or
AAAA (IPv6) record.
@@ -44,7 +44,7 @@ is either the integer 4 or 6 and denotes the family of `address` (not
necessarily the value initially passed to `lookup`).
-### dns.resolve(domain, [rrtype], callback)
+## dns.resolve(domain, [rrtype], callback)
Resolves a domain (e.g. `'google.com'`) into an array of the record types
specified by rrtype. Valid rrtypes are `'A'` (IPV4 addresses, default),
@@ -61,50 +61,50 @@ one of the error codes listed below and `err.message` is a string describing
the error in English.
-### dns.resolve4(domain, callback)
+## dns.resolve4(domain, callback)
The same as `dns.resolve()`, but only for IPv4 queries (`A` records).
`addresses` is an array of IPv4 addresses (e.g.
`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
-### dns.resolve6(domain, callback)
+## dns.resolve6(domain, callback)
The same as `dns.resolve4()` except for IPv6 queries (an `AAAA` query).
-### dns.resolveMx(domain, callback)
+## dns.resolveMx(domain, callback)
The same as `dns.resolve()`, but only for mail exchange queries (`MX` records).
`addresses` is an array of MX records, each with a priority and an exchange
attribute (e.g. `[{'priority': 10, 'exchange': 'mx.example.com'},...]`).
-### dns.resolveTxt(domain, callback)
+## dns.resolveTxt(domain, callback)
The same as `dns.resolve()`, but only for text queries (`TXT` records).
`addresses` is an array of the text records available for `domain` (e.g.,
`['v=spf1 ip4:0.0.0.0 ~all']`).
-### dns.resolveSrv(domain, callback)
+## dns.resolveSrv(domain, callback)
The same as `dns.resolve()`, but only for service records (`SRV` records).
`addresses` is an array of the SRV records available for `domain`. Properties
of SRV records are priority, weight, port, and name (e.g.,
`[{'priority': 10, {'weight': 5, 'port': 21223, 'name': 'service.example.com'}, ...]`).
-### dns.reverse(ip, callback)
+## dns.reverse(ip, callback)
Reverse resolves an ip address to an array of domain names.
The callback has arguments `(err, domains)`.
-### dns.resolveNs(domain, callback)
+## dns.resolveNs(domain, callback)
The same as `dns.resolve()`, but only for name server records (`NS` records).
`addresses` is an array of the name server records available for `domain`
(e.g., `['ns1.example.com', 'ns2.example.com']`).
-### dns.resolveCname(domain, callback)
+## dns.resolveCname(domain, callback)
The same as `dns.resolve()`, but only for canonical name records (`CNAME`
records). `addresses` is an array of the canonical name records available for
View
25 doc/api/events.markdown
@@ -1,4 +1,4 @@
-## Events
+# Events
Many objects in Node emit events: a `net.Server` emits an event each time
a peer connects to it, a `fs.readStream` emits an event when the file is
@@ -12,7 +12,7 @@ Functions can then be attached to objects, to be executed when an event
is emitted. These functions are called _listeners_.
-### events.EventEmitter
+## Class: events.EventEmitter
To access the EventEmitter class, `require('events').EventEmitter`.
@@ -24,8 +24,8 @@ trace and exit the program.
All EventEmitters emit the event `'newListener'` when new listeners are
added.
-#### emitter.addListener(event, listener)
-#### emitter.on(event, listener)
+### emitter.addListener(event, listener)
+### emitter.on(event, listener)
Adds a listener to the end of the listeners array for the specified event.
@@ -33,7 +33,7 @@ Adds a listener to the end of the listeners array for the specified event.
console.log('someone connected!');
});
-#### emitter.once(event, listener)
+### emitter.once(event, listener)
Adds a **one time** listener for the event. This listener is
invoked only the next time the event is fired, after which
@@ -43,7 +43,7 @@ it is removed.
console.log('Ah, we have our first user!');
});
-#### emitter.removeListener(event, listener)
+### emitter.removeListener(event, listener)
Remove a listener from the listener array for the specified event.
**Caution**: changes array indices in the listener array behind the listener.
@@ -56,12 +56,12 @@ Remove a listener from the listener array for the specified event.
server.removeListener('connection', callback);
-#### emitter.removeAllListeners([event])
+### emitter.removeAllListeners([event])
Removes all listeners, or those of the specified event.
-#### emitter.setMaxListeners(n)
+### emitter.setMaxListeners(n)
By default EventEmitters will print a warning if more than 10 listeners are
added for a particular event. This is a useful default which helps finding memory leaks.
@@ -69,7 +69,7 @@ Obviously not all Emitters should be limited to 10. This function allows
that to be increased. Set to zero for unlimited.
-#### emitter.listeners(event)
+### emitter.listeners(event)
Returns an array of listeners for the specified event. This array can be
manipulated, e.g. to remove listeners.
@@ -79,12 +79,13 @@ manipulated, e.g. to remove listeners.
});
console.log(util.inspect(server.listeners('connection'))); // [ [Function] ]
-#### emitter.emit(event, [arg1], [arg2], [...])
+### emitter.emit(event, [arg1], [arg2], [...])
Execute each of the listeners in order with the supplied arguments.
-#### Event: 'newListener'
+### Event: 'newListener'
-`function (event, listener) { }`
+* `event` {String} The event name
+* `listener` {Function} The event handler function
This event is emitted any time someone adds a new listener.
View
183 doc/api/fs.markdown
@@ -1,4 +1,4 @@
-## File System
+# File System
File I/O is provided by simple wrappers around standard POSIX functions. To
use this module do `require('fs')`. All the methods have asynchronous and
@@ -58,195 +58,195 @@ the entire process until they complete--halting all connections.
Relative path to filename can be used, remember however that this path will be relative
to `process.cwd()`.
-### fs.rename(path1, path2, [callback])
+## fs.rename(path1, path2, [callback])
Asynchronous rename(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.renameSync(path1, path2)
+## fs.renameSync(path1, path2)
Synchronous rename(2).
-### fs.truncate(fd, len, [callback])
+## fs.truncate(fd, len, [callback])
Asynchronous ftruncate(2). No arguments other than a possible exception are
given to the completion callback.
-### fs.truncateSync(fd, len)
+## fs.truncateSync(fd, len)
Synchronous ftruncate(2).
-### fs.chown(path, uid, gid, [callback])
+## fs.chown(path, uid, gid, [callback])
Asynchronous chown(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.chownSync(path, uid, gid)
+## fs.chownSync(path, uid, gid)
Synchronous chown(2).
-### fs.fchown(fd, uid, gid, [callback])
+## fs.fchown(fd, uid, gid, [callback])
Asynchronous fchown(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.fchownSync(fd, uid, gid)
+## fs.fchownSync(fd, uid, gid)
Synchronous fchown(2).
-### fs.lchown(path, uid, gid, [callback])
+## fs.lchown(path, uid, gid, [callback])
Asynchronous lchown(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.lchownSync(path, uid, gid)
+## fs.lchownSync(path, uid, gid)
Synchronous lchown(2).
-### fs.chmod(path, mode, [callback])
+## fs.chmod(path, mode, [callback])
Asynchronous chmod(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.chmodSync(path, mode)
+## fs.chmodSync(path, mode)
Synchronous chmod(2).
-### fs.fchmod(fd, mode, [callback])
+## fs.fchmod(fd, mode, [callback])
Asynchronous fchmod(2). No arguments other than a possible exception
are given to the completion callback.
-### fs.fchmodSync(fd, mode)
+## fs.fchmodSync(fd, mode)
Synchronous fchmod(2).
-### fs.lchmod(path, mode, [callback])
+## fs.lchmod(path, mode, [callback])
Asynchronous lchmod(2). No arguments other than a possible exception
are given to the completion callback.
-### fs.lchmodSync(path, mode)
+## fs.lchmodSync(path, mode)
Synchronous lchmod(2).
-### fs.stat(path, [callback])
+## fs.stat(path, [callback])
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
`stats` is a [fs.Stats](#fs.Stats) object. See the [fs.Stats](#fs.Stats)
section below for more information.
-### fs.lstat(path, [callback])
+## fs.lstat(path, [callback])
Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
`stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if
`path` is a symbolic link, then the link itself is stat-ed, not the file that it
refers to.
-### fs.fstat(fd, [callback])
+## fs.fstat(fd, [callback])
Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
`stats` is a `fs.Stats` object. `fstat()` is identical to `stat()`, except that
the file to be stat-ed is specified by the file descriptor `fd`.
-### fs.statSync(path)
+## fs.statSync(path)
Synchronous stat(2). Returns an instance of `fs.Stats`.
-### fs.lstatSync(path)
+## fs.lstatSync(path)
Synchronous lstat(2). Returns an instance of `fs.Stats`.
-### fs.fstatSync(fd)
+## fs.fstatSync(fd)
Synchronous fstat(2). Returns an instance of `fs.Stats`.
-### fs.link(srcpath, dstpath, [callback])
+## fs.link(srcpath, dstpath, [callback])
Asynchronous link(2). No arguments other than a possible exception are given to
the completion callback.
-### fs.linkSync(srcpath, dstpath)
+## fs.linkSync(srcpath, dstpath)
Synchronous link(2).
-### fs.symlink(linkdata, path, [type], [callback])
+## fs.symlink(linkdata, path, [type], [callback])
Asynchronous symlink(2). No arguments other than a possible exception are given
to the completion callback.
`type` argument can be either `'dir'` or `'file'` (default is `'file'`). It is only
used on Windows (ignored on other platforms).
-### fs.symlinkSync(linkdata, path, [type])
+## fs.symlinkSync(linkdata, path, [type])
Synchronous symlink(2).
-### fs.readlink(path, [callback])
+## fs.readlink(path, [callback])
Asynchronous readlink(2). The callback gets two arguments `(err,
linkString)`.
-### fs.readlinkSync(path)
+## fs.readlinkSync(path)
Synchronous readlink(2). Returns the symbolic link's string value.
-### fs.realpath(path, [callback])
+## fs.realpath(path, [callback])
Asynchronous realpath(2). The callback gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths.
-### fs.realpathSync(path)
+## fs.realpathSync(path)
Synchronous realpath(2). Returns the resolved path.
-### fs.unlink(path, [callback])
+## fs.unlink(path, [callback])
Asynchronous unlink(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.unlinkSync(path)
+## fs.unlinkSync(path)
Synchronous unlink(2).
-### fs.rmdir(path, [callback])
+## fs.rmdir(path, [callback])
Asynchronous rmdir(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.rmdirSync(path)
+## fs.rmdirSync(path)
Synchronous rmdir(2).
-### fs.mkdir(path, [mode], [callback])
+## fs.mkdir(path, [mode], [callback])
Asynchronous mkdir(2). No arguments other than a possible exception are given
to the completion callback. `mode` defaults to `0777`.
-### fs.mkdirSync(path, [mode])
+## fs.mkdirSync(path, [mode])
Synchronous mkdir(2).
-### fs.readdir(path, [callback])
+## fs.readdir(path, [callback])
Asynchronous readdir(3). Reads the contents of a directory.
The callback gets two arguments `(err, files)` where `files` is an array of
the names of the files in the directory excluding `'.'` and `'..'`.
-### fs.readdirSync(path)
+## fs.readdirSync(path)
Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
`'..'`.
-### fs.close(fd, [callback])
+## fs.close(fd, [callback])
Asynchronous close(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.closeSync(fd)
+## fs.closeSync(fd)
Synchronous close(2).
-### fs.open(path, flags, [mode], [callback])
+## fs.open(path, flags, [mode], [callback])
Asynchronous file open. See open(2). `flags` can be:
@@ -282,31 +282,31 @@ Exclusive mode (`O_EXCL`) ensures that `path` is newly created. `fs.open()`
fails if a file by that name already exists. On POSIX systems, symlinks are
not followed. Exclusive mode may or may not work with network file systems.
-### fs.openSync(path, flags, [mode])
+## fs.openSync(path, flags, [mode])
Synchronous open(2).
-### fs.utimes(path, atime, mtime, [callback])
-### fs.utimesSync(path, atime, mtime)
+## fs.utimes(path, atime, mtime, [callback])
+## fs.utimesSync(path, atime, mtime)
Change file timestamps of the file referenced by the supplied path.
-### fs.futimes(fd, atime, mtime, [callback])
-### fs.futimesSync(fd, atime, mtime)
+## fs.futimes(fd, atime, mtime, [callback])
+## fs.futimesSync(fd, atime, mtime)
Change the file timestamps of a file referenced by the supplied file
descriptor.
-### fs.fsync(fd, [callback])
+## fs.fsync(fd, [callback])
Asynchronous fsync(2). No arguments other than a possible exception are given
to the completion callback.
-### fs.fsyncSync(fd)
+## fs.fsyncSync(fd)
Synchronous fsync(2).
-### fs.write(fd, buffer, offset, length, position, [callback])
+## fs.write(fd, buffer, offset, length, position, [callback])
Write `buffer` to the file specified by `fd`.
@@ -324,17 +324,17 @@ Note that it is unsafe to use `fs.write` multiple times on the same file
without waiting for the callback. For this scenario,
`fs.createWriteStream` is strongly recommended.
-### fs.writeSync(fd, buffer, offset, length, position)
+## fs.writeSync(fd, buffer, offset, length, position)
Synchronous version of buffer-based `fs.write()`. Returns the number of bytes
written.
-### fs.writeSync(fd, str, position, [encoding])
+## fs.writeSync(fd, str, position, [encoding])
Synchronous version of string-based `fs.write()`. `encoding` defaults to
`'utf8'`. Returns the number of _bytes_ written.
-### fs.read(fd, buffer, offset, length, position, [callback])
+## fs.read(fd, buffer, offset, length, position, [callback])
Read data from the file specified by `fd`.
@@ -349,17 +349,17 @@ If `position` is `null`, data will be read from the current file position.
The callback is given the three arguments, `(err, bytesRead, buffer)`.
-### fs.readSync(fd, buffer, offset, length, position)
+## fs.readSync(fd, buffer, offset, length, position)
Synchronous version of buffer-based `fs.read`. Returns the number of
`bytesRead`.
-### fs.readSync(fd, length, position, encoding)
+## fs.readSync(fd, length, position, encoding)
Synchronous version of string-based `fs.read`. Returns the number of
`bytesRead`.
-### fs.readFile(filename, [encoding], [callback])
+## fs.readFile(filename, [encoding], [callback])
Asynchronously reads the entire contents of a file. Example:
@@ -374,7 +374,7 @@ contents of the file.
If no encoding is specified, then the raw buffer is returned.
-### fs.readFileSync(filename, [encoding])
+## fs.readFileSync(filename, [encoding])
Synchronous version of `fs.readFile`. Returns the contents of the `filename`.
@@ -382,7 +382,7 @@ If `encoding` is specified then this function returns a string. Otherwise it
returns a buffer.
-### fs.writeFile(filename, data, [encoding], [callback])
+## fs.writeFile(filename, data, [encoding], [callback])
Asynchronously writes data to a file, replacing the file if it already exists.
`data` can be a string or a buffer. The `encoding` argument is ignored if
@@ -395,11 +395,11 @@ Example:
console.log('It\'s saved!');
});
-### fs.writeFileSync(filename, data, [encoding])
+## fs.writeFileSync(filename, data, [encoding])
The synchronous version of `fs.writeFile`.
-### fs.appendFile(filename, data, encoding='utf8', [callback])
+## fs.appendFile(filename, data, encoding='utf8', [callback])
Asynchronously append data to a file, creating the file if it not yet exists.
`data` can be a string or a buffer. The `encoding` argument is ignored if
@@ -412,11 +412,11 @@ Example:
console.log('The "data to append" was appended to file!');
});
-### fs.appendFileSync(filename, data, encoding='utf8')
+## fs.appendFileSync(filename, data, encoding='utf8')
The synchronous version of `fs.appendFile`.
-### fs.watchFile(filename, [options], listener)
+## fs.watchFile(filename, [options], listener)
Watch for changes on `filename`. The callback `listener` will be called each
time the file is accessed.
@@ -442,11 +442,11 @@ If you want to be notified when the file was modified, not just accessed
you need to compare `curr.mtime` and `prev.mtime`.
-### fs.unwatchFile(filename)
+## fs.unwatchFile(filename)
Stop watching for changes on `filename`.
-### fs.watch(filename, [options], listener)
+## fs.watch(filename, [options], listener)
Watch for changes on `filename`, where `filename` is either a file or a
directory. The returned object is [fs.FSWatcher](#fs.FSWatcher).
@@ -476,7 +476,7 @@ callback, and have some fallback logic if it is null.
}
});
-### fs.exists(p, [callback])
+## fs.exists(p, [callback])
Test whether or not the given path exists by checking with the file system.
Then call the `callback` argument with either true or false. Example:
@@ -486,11 +486,11 @@ Then call the `callback` argument with either true or false. Example:
});
-### fs.existsSync(p)
+## fs.existsSync(p)
Synchronous version of `fs.exists`.
-## fs.Stats
+## Class: fs.Stats
Objects returned from `fs.stat()`, `fs.lstat()` and `fs.fstat()` and their
synchronous counterparts are of this type.
@@ -533,17 +533,8 @@ be found in the [MDN JavaScript Reference][MDN-Date] page.
[MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
[MDN-Date-getTime]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime
-## fs.ReadStream
-`ReadStream` is a [Readable Stream](streams.html#readable_Stream).
-
-### Event: 'open'
-
-`function (fd) { }`
-
- `fd` is the file descriptor used by the ReadStream.
-
-### fs.createReadStream(path, [options])
+## fs.createReadStream(path, [options])
Returns a new ReadStream object (See `Readable Stream`).
@@ -565,22 +556,18 @@ An example to read the last 10 bytes of a file which is 100 bytes long:
fs.createReadStream('sample.txt', {start: 90, end: 99});
-## fs.WriteStream
+## Class: fs.ReadStream
-`WriteStream` is a [Writable Stream](streams.html#writable_Stream).
+`ReadStream` is a [Readable Stream](streams.html#readable_Stream).
### Event: 'open'
`function (fd) { }`
- `fd` is the file descriptor used by the WriteStream.
-
-### file.bytesWritten
+ `fd` is the file descriptor used by the ReadStream.
-The number of bytes written so far. Does not include data that is still queued
-for writing.
-### fs.createWriteStream(path, [options])
+## fs.createWriteStream(path, [options])
Returns a new WriteStream object (See `Writable Stream`).
@@ -595,22 +582,38 @@ some position past the beginning of the file. Modifying a file rather
than replacing it may require a `flags` mode of `r+` rather than the
default mode `w`.
-## fs.FSWatcher
+## fs.WriteStream
+
+`WriteStream` is a [Writable Stream](streams.html#writable_Stream).
+
+### Event: 'open'
+
+`function (fd) { }`
+
+ `fd` is the file descriptor used by the WriteStream.
+
+### file.bytesWritten
+
+The number of bytes written so far. Does not include data that is still queued
+for writing.
+
+## Class: fs.FSWatcher
Objects returned from `fs.watch()` are of this type.
-#### watcher.close()
+### watcher.close()
Stop watching for changes on the given `fs.FSWatcher`.
-#### Event: 'change'
+### Event: 'change'
-`function (event, filename) {}`
+* `event` {String} The type of fs change
+* `filename` {String} The filename that changed (if relevant/available)
Emitted when something changes in a watched directory or file.
See more details in [fs.watch](#fs.watch).
-#### Event: 'error'
+### Event: 'error'
`function (exception) {}`
View
70 doc/api/globals.markdown
@@ -1,30 +1,50 @@
-## Global Objects
+# Global Objects
+
+<!-- type=misc -->
These objects are available in all modules. Some of these objects aren't
actually in the global scope but in the module scope - this will be noted.
-### global
+## global
+
+<!-- type=global -->
-The global namespace object.
+* {Object} The global namespace object.
In browsers, the top-level scope is the global scope. That means that in
browsers if you're in the global scope `var something` will define a global
variable. In Node this is different. The top-level scope is not the global
scope; `var something` inside a Node module will be local to that module.
-### process
+## process
+
+<!-- type=global -->
+
+* {Object}
The process object. See the [process object](process.html#process) section.
-### console
+## console
+
+<!-- type=global -->
+
+* {Object}
Used to print to stdout and stderr. See the [stdio](stdio.html) section.
-### Buffer
+## Buffer
+
+<!-- type=global -->
+
+* {Object}
Used to handle binary data. See the [buffers](buffers.html) section.
-### require()
+## require()
+
+<!-- type=var -->
+
+* {Function}
To require modules. See the [Modules](modules.html#modules) section.
`require` isn't actually a global but rather local to each module.
@@ -37,11 +57,16 @@ but rather than loading the module, just return the resolved filename.
### require.cache
+* {Object}
+
Modules are cached in this object when they are required. By deleting a key
value from this object, the next `require` will reload the module.
+## __filename
+
+<!-- type=var -->
-### __filename
+* {String}
The filename of the code being executed. This is the resolved absolute path
of this code file. For a main program this is not necessarily the same
@@ -55,7 +80,11 @@ Example: running `node example.js` from `/Users/mjr`
`__filename` isn't actually a global but rather local to each module.
-### __dirname
+## __dirname
+
+<!-- type=var -->
+
+* {String}
The name of the directory that the currently executing script resides in.
@@ -67,15 +96,22 @@ Example: running `node example.js` from `/Users/mjr`
`__dirname` isn't actually a global but rather local to each module.
-### module
+## module
+
+<!-- type=var -->
+
+* {Object}
A reference to the current module. In particular
`module.exports` is the same as the `exports` object. See `src/node.js`
for more information.
`module` isn't actually a global but rather local to each module.
+See the [module section](modules.html) for more information.
+
+## exports
-### exports
+<!-- type=var -->
An object which is shared between all instances of the current module and
made accessible through `require()`.
@@ -83,9 +119,13 @@ made accessible through `require()`.
for more information.
`exports` isn't actually a global but rather local to each module.
-### setTimeout(cb, ms)
-### clearTimeout(t)
-### setInterval(cb, ms)
-### clearInterval(t)
+See the [module section](modules.html) for more information.
+
+## setTimeout(cb, ms)
+## clearTimeout(t)
+## setInterval(cb, ms)
+## clearInterval(t)
+
+<!--type=global-->
The timer functions are global variables. See the [timers](timers.html) section.
View
35 doc/api/http.markdown
@@ -1,4 +1,4 @@
-## HTTP
+# HTTP
To use the HTTP server and client one must `require('http')`.
@@ -23,7 +23,14 @@ parsing only. It parses a message into headers and body but it does not
parse the actual headers or the body.
-## http.Server
+## http.createServer([requestListener])
+
+Returns a new web server object.
+
+The `requestListener` is a function which is automatically
+added to the `'request'` event.
+
+## Class: http.Server
This is an `EventEmitter` with the following events:
@@ -108,13 +115,6 @@ sent to the server on that socket.
If a client connection emits an 'error' event - it will forwarded here.
-### http.createServer([requestListener])
-
-Returns a new web server object.
-
-The `requestListener` is a function which is automatically
-added to the `'request'` event.
-
### server.listen(port, [hostname], [callback])
Begin accepting connections on the specified port and hostname. If the
@@ -149,7 +149,7 @@ Limits maximum incoming headers count, equal to 1000 by default. If set to 0 -
no limit will be applied.
-## http.ServerRequest
+## Class: http.ServerRequest
This object is created internally by a HTTP server -- not by
the user -- and passed as the first argument to a `'request'` listener.
@@ -269,7 +269,7 @@ authentication details.
-## http.ServerResponse
+## Class: http.ServerResponse
This object is created internally by a HTTP server--not by the user. It is
passed as the second parameter to the `'request'` event.
@@ -524,7 +524,7 @@ Example:
});
-## http.Agent
+## Class: http.Agent
In node 0.5.3+ there is a new implementation of the HTTP Agent which is used
for pooling sockets used in HTTP client requests.
@@ -555,10 +555,6 @@ Alternatively, you could just opt out of pooling entirely using `agent:false`:
// Do stuff
})
-## http.globalAgent
-
-Global instance of Agent which is used as the default for all http client requests.
-
### agent.maxSockets
By default set to 5. Determines how many concurrent sockets the agent can have
@@ -574,8 +570,13 @@ modify.
An object which contains queues of requests that have not yet been assigned to
sockets. Do not modify.
+## http.globalAgent
+
+Global instance of Agent which is used as the default for all http client
+requests.
+
-## http.ClientRequest
+## Class: http.ClientRequest
This object is created internally and returned from `http.request()`. It
represents an _in-progress_ request whose header has already been queued. The
View
6 doc/api/https.markdown
@@ -1,9 +1,9 @@
-## HTTPS
+# HTTPS
HTTPS is the HTTP protocol over TLS/SSL. In Node this is implemented as a
separate module.
-## https.Server
+## Class: https.Server
This class is a subclass of `tls.Server` and emits events same as
`http.Server`. See `http.Server` for more information.
@@ -156,7 +156,7 @@ Example:
});
-## https.Agent
+## Class: https.Agent
An Agent object for HTTPS similar to [http.Agent](http.html#http.Agent).
See [https.request()](#https.request) for more information.
View
26 doc/api/modules.markdown
@@ -1,4 +1,4 @@
-## Modules
+# Modules
Node has a simple module loading system. In Node, files and modules are in
one-to-one correspondence. As an example, `foo.js` loads the module
@@ -30,7 +30,7 @@ Variables
local to the module will be private. In this example the variable `PI` is
private to `circle.js`.
-### Cycles
+## Cycles
When there are circular `require()` calls, a module might not be
done being executed when it is returned.
@@ -84,7 +84,7 @@ The output of this program would thus be:
If you have cyclic module dependencies in your program, make sure to
plan accordingly.
-### Core Modules
+## Core Modules
Node has several modules compiled into the binary. These modules are
described in greater detail elsewhere in this documentation.
@@ -95,7 +95,7 @@ Core modules are always preferentially loaded if their identifier is
passed to `require()`. For instance, `require('http')` will always
return the built in HTTP module, even if there is a file by that name.
-### File Modules
+## File Modules
If the exact filename is not found, then node will attempt to load the
required filename with the added extension of `.js`, `.json`, and then `.node`.
@@ -118,7 +118,7 @@ Without a leading '/' or './' to indicate a file, the module is either a
If the given path does not exist, `require()` will throw an Error with its
`code` property set to `'MODULE_NOT_FOUND'`.
-### Loading from `node_modules` Folders
+## Loading from `node_modules` Folders
If the module identifier passed to `require()` is not a native module,
and does not begin with `'/'`, `'../'`, or `'./'`, then node starts at the
@@ -140,7 +140,7 @@ this order:
This allows programs to localize their dependencies, so that they do not
clash.
-### Folders as Modules
+## Folders as Modules
It is convenient to organize programs and libraries into self-contained
directories, and then provide a single entry point to that library.
@@ -168,7 +168,7 @@ example, then `require('./some-library')` would attempt to load:
* `./some-library/index.js`
* `./some-library/index.node`
-### Caching
+## Caching
Modules are cached after the first time they are loaded. This means
(among other things) that every call to `require('foo')` will get
@@ -182,7 +182,7 @@ dependencies to be loaded even when they would cause cycles.
If you want to have a module execute code multiple times, then export a
function, and call that function.
-#### Module Caching Caveats
+### Module Caching Caveats
Modules are cached based on their resolved filename. Since modules may
resolve to a different filename based on the location of the calling
@@ -190,7 +190,7 @@ module (loading from `node_modules` folders), it is not a *guarantee*
that `require('foo')` will always return the exact same object, if it
would resolve to different files.
-### module.exports
+## module.exports
The `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
@@ -230,7 +230,7 @@ y.js:
console.log(x.a);
-### module.require
+## module.require
The `module.require` method provides a way to load a module as if
`require()` was called from the original module.
@@ -241,7 +241,7 @@ typically *only* available within a specific module's code, it must be
explicitly exported in order to be used.
-### All Together...
+## All Together...
To get the exact filename that will be loaded when `require()` is called, use
the `require.resolve()` function.
@@ -290,7 +290,7 @@ in pseudocode of what require.resolve does:
c. let I = I - 1
6. return DIRS
-### Loading from the global folders
+## Loading from the global folders
If the `NODE_PATH` environment variable is set to a colon-delimited list
of absolute paths, then node will search those paths for modules if they
@@ -310,7 +310,7 @@ These are mostly for historic reasons. You are highly encouraged to
place your dependencies locally in `node_modules` folders. They will be
loaded faster, and more reliably.
-### Accessing the main module
+## Accessing the main module
When a file is run directly from Node, `require.main` is set to its
`module`. That means that you can determine whether a file has been run
View
111 doc/api/net.markdown
@@ -1,10 +1,10 @@
-## net
+# net
The `net` module provides you with an asynchronous network wrapper. It contains
methods for creating both servers and clients (called streams). You can include
this module with `require('net');`
-### net.createServer([options], [connectionListener])
+## net.createServer([options], [connectionListener])
Creates a new TCP server. The `connectionListener` argument is
automatically set as a listener for the ['connection'](#event_connection_)
@@ -49,8 +49,8 @@ Use `nc` to connect to a UNIX domain socket server:
nc -U /tmp/echo.sock
-### net.connect(options, [cnnectionListener])
-### net.createConnection(options, [cnnectionListener])
+## net.connect(options, [cnnectionListener])
+## net.createConnection(options, [cnnectionListener])
Constructs a new socket object and opens the socket to the given location.
When the socket is established, the ['connect'](#event_connect_) event will be
@@ -97,29 +97,27 @@ changed to
var client = net.connect({path: '/tmp/echo.sock'},
-### net.connect(port, [host], [connectListener])
-### net.createConnection(port, [host], [connectListener])
+## net.connect(port, [host], [connectListener])
+## net.createConnection(port, [host], [connectListener])
Creates a TCP connection to `port` on `host`. If `host` is omitted,
`'localhost'` will be assumed.
The `connectListener` parameter will be added as an listener for the
['connect'](#event_connect_) event.
-### net.connect(path, [connectListener])
-### net.createConnection(path, [connectListener])
+## net.connect(path, [connectListener])
+## net.createConnection(path, [connectListener])
Creates unix socket connection to `path`.
The `connectListener` parameter will be added as an listener for the
['connect'](#event_connect_) event.
----
-
-### net.Server
+## Class: net.Server
This class is used to create a TCP or UNIX server.
A server is a `net.Socket` that can listen for new incoming connections.
-#### server.listen(port, [host], [listeningListener])
+### server.listen(port, [host], [listeningListener])
Begin accepting connections on the specified `port` and `host`. If the
`host` is omitted, the server will accept connections directed to any
@@ -147,7 +145,7 @@ would be to wait a second and then try again. This can be done with
(Note: All sockets in Node set `SO_REUSEADDR` already)
-#### server.listen(path, [listeningListener])
+### server.listen(path, [listeningListener])
Start a UNIX socket server listening for connections on the given `path`.
@@ -156,20 +154,20 @@ This function is asynchronous. When the server has been bound,
the last parameter `listeningListener` will be added as an listener for the
['listening'](#event_listening_) event.
-#### server.pause(msecs)
+### server.pause(msecs)
Stop accepting connections for the given number of milliseconds (default is
one second). This could be useful for throttling new connections against
DoS attacks or other oversubscription.
-#### server.close()
+### server.close()
Stops the server from accepting new connections. This function is
asynchronous, the server is finally closed when the server emits a `'close'`
event.
-#### server.address()
+### server.address()
Returns the bound address and port of the server as reported by the operating system.
Useful to find which port was assigned when giving getting an OS-assigned address.
@@ -189,54 +187,52 @@ Example:
Don't call `server.address()` until the `'listening'` event has been emitted.
-#### server.maxConnections
+### server.maxConnections
Set this property to reject connections when the server's connection count gets
high.
-#### server.connections
+### server.connections
The number of concurrent connections on the server.
`net.Server` is an `EventEmitter` with the following events:
-#### Event: 'listening'
+### Event: 'listening'
`function () {}`
Emitted when the server has been bound after calling `server.listen`.
-#### Event: 'connection'
+### Event: 'connection'
`function (socket) {}`
Emitted when a new connection is made. `socket` is an instance of
`net.Socket`.
-#### Event: 'close'
+### Event: 'close'
`function () {}`
Emitted when the server closes.
-#### Event: 'error'
+### Event: 'error'
`function (exception) {}`
Emitted when an error occurs. The `'close'` event will be called directly
following this event. See example in discussion of `server.listen`.
----
-
-### net.Socket
+## Class: net.Socket
This object is an abstraction of a TCP or UNIX socket. `net.Socket`
instances implement a duplex Stream interface. They can be created by the
user and used as a client (with `connect()`) or they can be created by Node
and passed to the user through the `'connection'` event of a server.
-#### new net.Socket([options])
+### new net.Socket([options])
Construct a new socket object.
@@ -251,8 +247,8 @@ Construct a new socket object.
specified underlying protocol. It can be `'tcp4'`, `'tcp6'`, or `'unix'`.
About `allowHalfOpen`, refer to `createServer()` and `'end'` event.
-#### socket.connect(port, [host], [connectListener])
-#### socket.connect(path, [connectListener])
+### socket.connect(port, [host], [connectListener])
+### socket.connect(path, [connectListener])
Opens the connection for a given socket. If `port` and `host` are given,
then the socket will be opened as a TCP socket, if `host` is omitted,
@@ -272,7 +268,7 @@ The `connectListener` parameter will be added as an listener for the
['connect'](#event_connect_) event.
-#### socket.bufferSize
+### socket.bufferSize
`net.Socket` has the property that `socket.write()` always works. This is to
help users get up and running quickly. The computer cannot always keep up
@@ -291,18 +287,18 @@ Users who experience large or growing `bufferSize` should attempt to
"throttle" the data flows in their program with `pause()` and `resume()`.
-#### socket.setEncoding([encoding])
+### socket.setEncoding([encoding])
Sets the encoding (either `'ascii'`, `'utf8'`, or `'base64'`) for data that is
received. Defaults to `null`.
-#### socket.setSecure()
+### socket.setSecure()
This function has been removed in v0.3. It used to upgrade the connection to
SSL/TLS. See the [TLS section](tls.html#tLS_) for the new API.
-#### socket.write(data, [encoding], [callback])
+### socket.write(data, [encoding], [callback])
Sends data on the socket. The second parameter specifies the encoding in the
case of a string--it defaults to UTF8 encoding.
@@ -314,12 +310,12 @@ buffer. Returns `false` if all or part of the data was queued in user memory.
The optional `callback` parameter will be executed when the data is finally
written out - this may not be immediately.
-#### socket.write(data, [encoding], [callback])
+### socket.write(data, [encoding], [callback])
Write data with the optional encoding. The callback will be made when the
data is flushed to the kernel.
-#### socket.end([data], [encoding])
+### socket.end([data], [encoding])
Half-closes the socket. i.e., it sends a FIN packet. It is possible the
server will still send some data.
@@ -327,21 +323,21 @@ server will still send some data.
If `data` is specified, it is equivalent to calling
`socket.write(data, encoding)` followed by `socket.end()`.
-#### socket.destroy()
+### socket.destroy()
Ensures that no more I/O activity happens on this socket. Only necessary in
case of errors (parse error or so).
-#### socket.pause()
+### socket.pause()
Pauses the reading of data. That is, `'data'` events will not be emitted.
Useful to throttle back an upload.
-#### socket.resume()
+### socket.resume()
Resumes reading after a call to `pause()`.
-#### socket.setTimeout(timeout, [callback])
+### socket.setTimeout(timeout, [callback])
Sets the socket to timeout after `timeout` milliseconds of inactivity on
the socket. By default `net.Socket` do not have a timeout.
@@ -355,14 +351,14 @@ If `timeout` is 0, then the existing idle timeout is disabled.
The optional `callback` parameter will be added as a one time listener for the
`'timeout'` event.
-#### socket.setNoDelay([noDelay])
+### socket.setNoDelay([noDelay])
Disables the Nagle algorithm. By default TCP connections use the Nagle
algorithm, they buffer data before sending it off. Setting `true` for
`noDelay` will immediately fire off data each time `socket.write()` is called.
`noDelay` defaults to `true`.
-#### socket.setKeepAlive([enable], [initialDelay])
+### socket.setKeepAlive([enable], [initialDelay])
Enable/disable keep-alive functionality, and optionally set the initial
delay before the first keepalive probe is sent on an idle socket.
@@ -373,41 +369,41 @@ data packet received and the first keepalive probe. Setting 0 for
initialDelay will leave the value unchanged from the default
(or previous) setting. Defaults to `0`.
-#### socket.address()
+### socket.address()
Returns the bound address and port of the socket as reported by the operating
system. Returns an object with two properties, e.g.
`{"address":"192.168.57.1", "port":62053}`
-#### socket.remoteAddress
+### socket.remoteAddress
The string representation of the remote IP address. For example,
`'74.125.127.100'` or `'2001:4860:a005::68'`.
-#### socket.remotePort
+### socket.remotePort
The numeric representation of the remote port. For example,
`80` or `21`.
-#### socket.bytesRead
+### socket.bytesRead
The amount of received bytes.
-#### socket.bytesWritten
+### socket.bytesWritten
The amount of bytes sent.
`net.Socket` instances are EventEmitters with the following events:
-#### Event: 'connect'
+### Event: 'connect'
`function () { }`
Emitted when a socket connection is successfully established.
See `connect()`.
-#### Event: 'data'
+### Event: 'data'
`function (data) { }`
@@ -419,7 +415,7 @@ information.)
Note that the __data will be lost__ if there is no listener when a `Socket`
emits a `'data'` event.
-#### Event: 'end'
+### Event: 'end'
`function () { }`
@@ -432,7 +428,7 @@ its side allowing the user to write arbitrary amounts of data, with the
caveat that the user is required to `end()` their side now.
-#### Event: 'timeout'
+### Event: 'timeout'
`function () { }`
@@ -442,7 +438,7 @@ the socket has been idle. The user must manually close the connection.
See also: `socket.setTimeout()`
-#### Event: 'drain'
+### Event: 'drain'
`function () { }`
@@ -450,36 +446,33 @@ Emitted when the write buffer becomes empty. Can be used to throttle uploads.
See also: the return values of `socket.write()`
-#### Event: 'error'
+### Event: 'error'
`function (exception) { }`
Emitted when an error occurs. The `'close'` event will be called directly
following this event.
-#### Event: 'close'
+### Event: 'close'
`function (had_error) { }`
Emitted once the socket is fully closed. The argument `had_error` is a boolean
which says if the socket was closed due to a transmission error.
----
-
-### net.isIP
-
-#### net.isIP(input)
+## net.isIP
+## net.isIP(input)
Tests if input is an IP address. Returns 0 for invalid strings,
returns 4 for IP version 4 addresses, and returns 6 for IP version 6 addresses.
-#### net.isIPv4(input)
+## net.isIPv4(input)
Returns true if input is a version 4 IP address, otherwise returns false.
-#### net.isIPv6(input)
+## net.isIPv6(input)
Returns true if input is a version 6 IP address, otherwise returns false.
View
26 doc/api/os.markdown
@@ -1,44 +1,46 @@
-## os Module
+# os
+
+Provides a few basic operating-system related utility functions.
Use `require('os')` to access this module.
-### os.hostname()
+## os.hostname()
Returns the hostname of the operating system.
-### os.type()
+## os.type()
Returns the operating system name.
-### os.platform()
+## os.platform()
Returns the operating system platform.
-### os.arch()
+## os.arch()
Returns the operating system CPU architecture.
-### os.release()
+## os.release()
Returns the operating system release.
-### os.uptime()
+## os.uptime()
Returns the system uptime in seconds.
-### os.loadavg()
+## os.loadavg()
Returns an array containing the 1, 5, and 15 minute load averages.
-### os.totalmem()
+## os.totalmem()
Returns the total amount of system memory in bytes.
-### os.freemem()
+## os.freemem()
Returns the amount of free system memory in bytes.
-### os.cpus()
+## os.cpus()
Returns an array of objects containing information about each CPU/core installed: model, speed (in MHz), and times (an object containing the number of CPU ticks spent in: user, nice, sys, idle, and irq).
@@ -109,7 +111,7 @@ Example inspection of os.cpus:
idle: 1072572010,
irq: 30 } } ]
-### os.networkInterfaces()
+## os.networkInterfaces()
Get a list of network interfaces:
View
16 doc/api/path.markdown
@@ -1,4 +1,4 @@
-## Path
+# Path
This module contains utilities for handling and transforming file
paths. Almost all these methods perform only string transformations.
@@ -6,7 +6,7 @@ The file system is not consulted to check whether paths are valid.
Use `require('path')` to use this module. The following methods are provided:
-### path.normalize(p)
+## path.normalize(p)
Normalize a string path, taking care of `'..'` and `'.'` parts.
@@ -20,7 +20,7 @@ Example:
// returns
'/foo/bar/baz/asdf'
-### path.join([path1], [path2], [...])
+## path.join([path1], [path2], [...])
Join all arguments together and normalize the resulting path.
Non-string arguments are ignored.
@@ -35,7 +35,7 @@ Example:
// returns
'foo/bar'
-### path.resolve([from ...], to)
+## path.resolve([from ...], to)
Resolves `to` to an absolute path.
@@ -74,7 +74,7 @@ Examples:
// if currently in /home/myself/node, it returns
'/home/myself/node/wwwroot/static_files/gif/image.gif'
-### path.relative(from, to)
+## path.relative(from, to)
Solve the relative path from `from` to `to`.
@@ -94,7 +94,7 @@ Examples:
// returns
'../../impl/bbb'
-### path.dirname(p)
+## path.dirname(p)
Return the directory name of a path. Similar to the Unix `dirname` command.
@@ -104,7 +104,7 @@ Example:
// returns
'/foo/bar/baz/asdf'
-### path.basename(p, [ext])
+## path.basename(p, [ext])
Return the last portion of a path. Similar to the Unix `basename` command.
@@ -118,7 +118,7 @@ Example:
// returns
'quux'
-### path.extname(p)
+## path.extname(p)
Return the extension of the path, from the last '.' to end of string
in the last portion of the path. If there is no '.' in the last portion
View
65 doc/api/process.markdown
@@ -1,10 +1,12 @@
-## process
+# process
+
+<!-- type=global -->
The `process` object is a global object and can be accessed from anywhere.
It is an instance of `EventEmitter`.
-### Event: 'exit'
+## Event: 'exit'
`function () {}`
@@ -22,7 +24,7 @@ Example of listening for `exit`:
console.log('About to exit.');
});
-### Event: 'uncaughtException'
+## Event: 'uncaughtException'
`function (err) { }`
@@ -50,7 +52,10 @@ your program's flow. Especially for server programs that are designed to
stay running forever, `uncaughtException` can be a useful safety mechanism.
-### Signal Events
+## Signal Events
+
+<!--type=event-->
+<!--name=SIGINT, SIGUSR1, etc.-->
`function () {}`
@@ -70,7 +75,7 @@ An easy way to send the `SIGINT` signal is with `Control-C` in most terminal
programs.
-### process.stdout
+## process.stdout
A `Writable Stream` to `stdout`.
@@ -86,7 +91,7 @@ that they refer to regular files or TTY file descriptors. In the case they
refer to pipes, they are non-blocking like other streams.
-### process.stderr
+## process.stderr
A writable stream to stderr.
@@ -96,7 +101,7 @@ that they refer to regular files or TTY file descriptors. In the case they
refer to pipes, they are non-blocking like other streams.
-### process.stdin
+## process.stdin
A `Readable Stream` for stdin. The stdin stream is paused by default, so one
must call `process.stdin.resume()` to read from it.
@@ -115,7 +120,7 @@ Example of opening standard input and listening for both events:
});
-### process.argv
+## process.argv
An array containing the command line arguments. The first element will be
'node', the second element will be the name of the JavaScript file. The
@@ -136,7 +141,7 @@ This will generate:
4: four
-### process.execPath
+## process.execPath
This is the absolute pathname of the executable that started the process.
@@ -145,12 +150,12 @@ Example:
/usr/local/bin/node
-### process.abort()
+## process.abort()
This causes node to emit an abort. This will cause node to exit and
generate a core file.
-### process.chdir(directory)
+## process.chdir(directory)
Changes the current working directory of the process or throws an exception if that fails.
@@ -165,19 +170,19 @@ Changes the current working directory of the process or throws an exception if t
-### process.cwd()
+## process.cwd()
Returns the current working directory of the process.
console.log('Current directory: ' + process.cwd());
-### process.env
+## process.env
An object containing the user environment. See environ(7).
-### process.exit([code])
+## process.exit([code])
Ends the process with the specified `code`. If omitted, exit uses the
'success' code `0`.
@@ -189,7 +194,7 @@ To exit with a 'failure' code:
The shell that executed node should see the exit code as 1.
-### process.getgid()
+## process.getgid()
Gets the group identity of the process. (See getgid(2).)
This is the numerical group id, not the group name.
@@ -197,7 +202,7 @@ This is the numerical group id, not the group name.
console.log('Current gid: ' + process.getgid());
-### process.setgid(id)
+## process.setgid(id)
Sets the group identity of the process. (See setgid(2).) This accepts either
a numerical ID or a groupname string. If a groupname is specified, this method
@@ -213,7 +218,7 @@ blocks while resolving it to a numerical ID.
}
-### process.getuid()
+## process.getuid()
Gets the user identity of the process. (See getuid(2).)
This is the numerical userid, not the username.
@@ -221,7 +226,7 @@ This is the numerical userid, not the username.
console.log('Current uid: ' + process.getuid());
-### process.setuid(id)
+## process.setuid(id)
Sets the user identity of the process. (See setuid(2).) This accepts either
a numerical ID or a username string. If a username is specified, this method
@@ -237,13 +242,13 @@ blocks while resolving it to a numerical ID.
}
-### process.version
+## process.version
A compiled-in property that exposes `NODE_VERSION`.
console.log('Version: ' + process.version);
-### process.versions
+## process.versions
A property exposing version strings of node and its dependencies.
@@ -258,14 +263,14 @@ Will output:
openssl: '1.0.0e-fips' }
-### process.installPrefix
+## process.installPrefix
A compiled-in property that exposes `NODE_PREFIX`.
console.log('Prefix: ' + process.installPrefix);
-### process.kill(pid, [signal])
+## process.kill(pid, [signal])
Send a signal to a process. `pid` is the process id and `signal` is the
string describing the signal to send. Signal names are strings like
@@ -290,32 +295,32 @@ Example of sending a signal to yourself:
process.kill(process.pid, 'SIGHUP');
-### process.pid
+## process.pid
The PID of the process.
console.log('This process is pid ' + process.pid);
-### process.title
+## process.title
Getter/setter to set what is displayed in 'ps'.
-### process.arch
+## process.arch
What processor architecture you're running on: `'arm'`, `'ia32'`, or `'x64'`.
console.log('This processor architecture is ' + process.arch);
-### process.platform
+## process.platform
What platform you're running on. `'linux2'`, `'darwin'`, etc.
console.log('This platform is ' + process.platform);
-### process.memoryUsage()
+## process.memoryUsage()
Returns an object describing the memory usage of the Node process
measured in bytes.
@@ -333,7 +338,7 @@ This will generate:
`heapTotal` and `heapUsed` refer to V8's memory usage.
-### process.nextTick(callback)
+## process.nextTick(callback)
On the next loop around the event loop call this callback.
This is *not* a simple alias to `setTimeout(fn, 0)`, it's much more
@@ -344,7 +349,7 @@ efficient.
});
-### process.umask([mask])
+## process.umask([mask])
Sets or reads the process's file mode creation mask. Child processes inherit
the mask from the parent process. Returns the old mask if `mask` argument is
@@ -357,6 +362,6 @@ given, otherwise returns the current mask.
' to ' + newmask.toString(8));
-### process.uptime()
+## process.uptime()
Number of seconds Node has been running.
View
12 doc/api/querystring.markdown
@@ -1,9 +1,11 @@
-## Query String
+# Query String
+
+<!--name=querystring-->
This module provides utilities for dealing with query strings.
It provides the following methods:
-### querystring.stringify(obj, [sep], [eq])
+## querystring.stringify(obj, [sep], [eq])
Serialize an object to a query string.
Optionally override the default separator (`'&'`) and assignment (`'='`)
@@ -19,7 +21,7 @@ Example:
// returns
'foo:bar;baz:qux'
-### querystring.parse(str, [sep], [eq], [options])
+## querystring.parse(str, [sep], [eq], [options])
Deserialize a query string to an object.
Optionally override the default separator (`'&'`) and assignment (`'='`)
@@ -34,12 +36,12 @@ Example:
// returns
{ foo: 'bar', baz: ['qux', 'quux'], corge: '' }
-### querystring.escape
+## querystring.escape
The escape function used by `querystring.stringify`,
provided so that it could be overridden if necessary.
-### querystring.unescape
+## querystring.unescape
The unescape function used by `querystring.parse`,
provided so that it could be overridden if necessary.
View
11 doc/api/readline.markdown
@@ -1,4 +1,4 @@
-## Readline
+# Readline
To use this module, do `require('readline')`. Readline allows reading of a
stream (such as STDIN) on a line-by-line basis.
@@ -17,7 +17,7 @@ program to gracefully pause:
i.pause();
});
-### rl.createInterface(input, output, completer)
+## rl.createInterface(input, output, completer)
Takes two streams and creates a readline interface. The `completer` function
is used for autocompletion. When given a substring, it returns `[[substr1,
@@ -35,6 +35,11 @@ Also `completer` can be run in async mode if it accepts two arguments:
var readline = require('readline'),
rl = readline.createInterface(process.stdin, process.stdout);
+## Class: Interface
+
+The class that represents a readline interface with a stdin and stdout
+stream.
+
### rl.setPrompt(prompt, length)