The parameter parser specifically looked for the old bracket syntax.
This generated a lot of warnings when building the docs. Those warnings
have been fixed by changing the parsing logic.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Tests strict non-equality, as determined by the strict not equal operator ( `!==` )
-## assert.throws(block[, error]\[, message])
+## assert.throws(block[, error][, message])
Expects `block` to throw an error. `error` can be constructor, `RegExp` or
validation function.
// 1234
// 1234
-### buf.write(string[, offset]\[, length]\[, encoding])
+### buf.write(string[, offset][, length][, encoding])
* `string` String - data to be written to buffer
* `offset` Number, Optional, Default: 0
console.log(len + " bytes: " + buf.toString('utf8', 0, len));
-### buf.toString([encoding]\[, start]\[, end])
+### buf.toString([encoding][, start][, end])
* `encoding` String, Optional, Default: 'utf8'
* `start` Number, Optional, Default: 0
the same as the `otherBuffer` in sort order.
-### buf.copy(targetBuffer[, targetStart]\[, sourceStart]\[, sourceEnd])
+### buf.copy(targetBuffer[, targetStart][, sourceStart][, sourceEnd])
* `targetBuffer` Buffer object - Buffer to copy into
* `targetStart` Number, Optional, Default: 0
// !!!!!!!!qrst!!!!!!!!!!!!!
-### buf.slice([start]\[, end])
+### buf.slice([start][, end])
* `start` Number, Optional, Default: 0
* `end` Number, Optional, Default: `buffer.length`
// <Buffer 43 eb d5 b7 dd f9 5f d7>
// <Buffer d7 5f f9 dd b7 d5 eb 43>
-### buf.fill(value[, offset]\[, end])
+### buf.fill(value[, offset][, end])
* `value`
* `offset` Number, Optional
These methods follow the common async programming patterns (accepting a
callback or returning an EventEmitter).
-### child_process.spawn(command[, args]\[, options])
+### child_process.spawn(command[, args][, options])
* `command` {String} The command to run
* `args` {Array} List of string arguments
the child process is killed.
-### child_process.execFile(file[, args]\[, options]\[, callback])
+### child_process.execFile(file[, args][, options][, callback])
* `file` {String} The filename of the program to run
* `args` {Array} List of string arguments
leaner than `child_process.exec`. It has the same options.
-### child_process.fork(modulePath[, args]\[, options])
+### child_process.fork(modulePath[, args][, options])
* `modulePath` {String} The module to run in the child
* `args` {Array} List of string arguments
scripting tasks and for simplifying the loading/processing of application
configuration at startup.
-### child_process.spawnSync(command[, args]\[, options])
+### child_process.spawnSync(command[, args][, options])
* `command` {String} The command to run
* `args` {Array} List of string arguments
the `SIGTERM` signal and doesn't exit, your process will wait until the child
process has exited.
-### child_process.execFileSync(command[, args]\[, options])
+### child_process.execFileSync(command[, args][, options])
* `command` {String} The command to run
* `args` {Array} List of string arguments
should worry about unless you log huge amounts of data.
-## console.log([data]\[, ...])
+## console.log([data][, ...])
Prints to stdout with newline. This function can take multiple arguments in a
`printf()`-like way. Example:
If formatting elements are not found in the first string then `util.inspect`
is used on each argument. See [util.format()][] for more information.
-## console.info([data]\[, ...])
+## console.info([data][, ...])
Same as `console.log`.
-## console.error([data]\[, ...])
+## console.error([data][, ...])
Same as `console.log` but prints to stderr.
-## console.warn([data]\[, ...])
+## console.warn([data][, ...])
Same as `console.error`.
Print to stderr `'Trace :'`, followed by the formatted message and stack trace
to the current position.
-## console.assert(value[, message]\[, ...])
+## console.assert(value[, message][, ...])
Similar to [assert.ok()][], but the error message is formatted as
`util.format(message...)`.
encrypted data on the readable side. The legacy `update` and `final`
methods are also supported.
-### cipher.update(data[, input_encoding]\[, output_encoding])
+### cipher.update(data[, input_encoding][, output_encoding])
Updates the cipher with `data`, the encoding of which is given in
`input_encoding` and can be `'utf8'`, `'ascii'` or `'binary'`. If no
plain-text data on the the readable side. The legacy `update` and
`final` methods are also supported.
-### decipher.update(data[, input_encoding]\[, output_encoding])
+### decipher.update(data[, input_encoding][, output_encoding])
Updates the decipher with `data`, which is encoded in `'binary'`,
`'base64'` or `'hex'`. If no encoding is provided, then a buffer is
`prime_length` bits and using an optional specific numeric `generator`.
If no `generator` is specified, then `2` is used.
-## crypto.createDiffieHellman(prime[, prime_encoding]\[, generator]\[, generator_encoding])
+## crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_encoding])
Creates a Diffie-Hellman key exchange object using the supplied `prime` and an
optional specific `generator`.
transferred to the other party. Encoding can be `'binary'`, `'hex'`,
or `'base64'`. If no encoding is provided, then a buffer is returned.
-### diffieHellman.computeSecret(other_public_key[, input_encoding]\[, output_encoding])
+### diffieHellman.computeSecret(other_public_key[, input_encoding][, output_encoding])
Computes the shared secret using `other_public_key` as the other
party's public key and returns the computed shared secret. Supplied
Encoding can be `'binary'`, `'hex'`, or `'base64'`. If no encoding is provided,
then a buffer is returned.
-### ECDH.computeSecret(other_public_key[, input_encoding]\[, output_encoding])
+### ECDH.computeSecret(other_public_key[, input_encoding][, output_encoding])
Computes the shared secret using `other_public_key` as the other
party's public key and returns the computed shared secret. Supplied
## dgram.createSocket(type[, callback])
-## dgram.createSocket(options[, callback])
* `type` String. Either 'udp4' or 'udp6'
-* `options` Object. Should contain a `type` property and could contain
- `reuseAddr` property. `false` by default.
- When `reuseAddr` is `true` - `socket.bind()` will reuse address, even if the
- other process has already bound a socket on it.
* `callback` Function. Attached as a listener to `message` events.
Optional
* Returns: Socket object
Takes an optional callback which is added as a listener for `message` events.
-Call `socket.bind` if you want to receive datagrams. `socket.bind()` will bind
-to the "all interfaces" address on a random port (it does the right thing for
-both `udp4` and `udp6` sockets). You can then retrieve the address and port
+Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
+bind to the "all interfaces" address on a random port (it does the right thing
+for both `udp4` and `udp6` sockets). You can then retrieve the address and port
+with `socket.address().address` and `socket.address().port`.
+
+## dgram.createSocket(options[, callback])
+* `options` Object
+* `callback` Function. Attached as a listener to `message` events.
+* Returns: Socket object
+
+The `options` object should contain a `type` field of either `udp4` or `udp6`
+and an optional boolean `reuseAddr` field.
+
+When `reuseAddr` is true `socket.bind()` will reuse the address, even if
+another process has already bound a socket on it. `reuseAddr` defaults to
+`false`.
+
+Takes an optional callback which is added as a listener for `message` events.
+
+Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
+bind to the "all interfaces" address on a random port (it does the right thing
+for both `udp4` and `udp6` sockets). You can then retrieve the address and port
with `socket.address().address` and `socket.address().port`.
## Class: dgram.Socket
the (receiver) `MTU` won't work (the packet gets silently dropped, without
informing the source that the data did not reach its intended recipient).
-### socket.bind(port[, address]\[, callback])
+### socket.bind(port[, address][, callback])
* `port` Integer
* `address` String, Optional
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.
Calling `fs.unwatchFile()` with a filename that is not being watched is a
no-op, not an error.
-## fs.watch(filename[, options]\[, listener])
+## fs.watch(filename[, options][, listener])
Stability: 2 - Unstable.
The `requestListener` is a function which is automatically
added to the `'request'` event.
-## http.createClient([port]\[, host])
+## http.createClient([port][, host])
This function is **deprecated**; please use [http.request()][] instead.
Constructs a new HTTP client. `port` and `host` refer to the server to be
`socket` is the `net.Socket` object that the error originated from.
-### server.listen(port[, hostname]\[, backlog]\[, callback])
+### server.listen(port[, hostname][, backlog][, callback])
Begin accepting connections on the specified port and hostname. If the
hostname is omitted, the server will accept connections directed to any
Sends a HTTP/1.1 100 Continue message to the client, indicating that
the request body should be sent. See the ['checkContinue'][] event on `Server`.
-### response.writeHead(statusCode[, statusMessage]\[, headers])
+### response.writeHead(statusCode[, statusMessage][, headers])
Sends a response header to the request. The status code is a 3-digit HTTP
status code, like `404`. The last argument, `headers`, are the response headers.
response.end();
-### response.end([data]\[, encoding])
+### response.end([data][, encoding])
This method signals to the server that all of the response headers and body
have been sent; that server should consider this message complete.
Defaults to `'utf8'`.
-### request.end([data]\[, encoding])
+### request.end([data][, encoding])
Finishes sending the request. If any parts of the body are
unsent, it will flush them to the stream. If the request is
Once a socket is assigned to this request and is connected
[socket.setNoDelay()][] will be called.
-### request.setSocketKeepAlive([enable]\[, initialDelay])
+### request.setSocketKeepAlive([enable][, initialDelay])
Once a socket is assigned to this request and is connected
[socket.setKeepAlive()][] will be called.
}).listen(8000);
-### server.listen(port[, host]\[, backlog]\[, callback])
+### server.listen(port[, host][, backlog][, callback])
### server.listen(path[, callback])
### server.listen(handle[, callback])
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.
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.
This class is used to create a TCP or local server.
-### server.listen(port[, host]\[, backlog]\[, callback])
+### server.listen(port[, host][, backlog][, callback])
Begin accepting connections on the specified `port` and `host`. If the
`host` is omitted, the server will accept connections directed to any
socket (NOTE: Works only when `fd` is passed).
About `allowHalfOpen`, refer to `createServer()` and `'end'` event.
-### socket.connect(port[, host]\[, connectListener])
+### socket.connect(port[, host][, connectListener])
### socket.connect(path[, connectListener])
Opens the connection for a given socket. If `port` and `host` are given,
Set the encoding for the socket as a Readable Stream. See
[stream.setEncoding()][] for more information.
-### 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.
The optional `callback` parameter will be executed when the data is finally
written out - this may not be immediately.
-### 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.
`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.
// returns
'/foo/bar/baz/asdf'
-## path.join([path1]\[, path2]\[, ...])
+## path.join([path1][, path2][, ...])
Join all arguments together and normalize the resulting path.
This module provides utilities for dealing with query strings.
It provides the following methods:
-## querystring.stringify(obj[, sep]\[, eq]\[, options])
+## querystring.stringify(obj[, sep][, eq][, options])
Serialize an object to a query string.
Optionally override the default separator (`'&'`) and assignment (`'='`)
// returns
'w=%D6%D0%CE%C4&foo=bar'
-## 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 (`'='`)
Stability: 1 - Experimental
-## smalloc.alloc(length[, receiver][, type])
+## Class: smalloc
+
+Buffers are backed by a simple allocator that only handles the assignation of
+external raw memory. Smalloc exposes that functionality.
+
+### smalloc.alloc(length[, receiver][, type])
* `length` {Number} `<= smalloc.kMaxLength`
-* `receiver` {Object}, Optional, Default: `new Object`
-* `type` {Enum}, Optional, Default: `Uint8`
+* `receiver` {Object} Default: `new Object`
+* `type` {Enum} Default: `Uint8`
Returns `receiver` with allocated external array data. If no `receiver` is
passed then a new Object will be created and returned.
-Buffers are backed by a simple allocator that only handles the assignation of
-external raw memory. Smalloc exposes that functionality.
-
This can be used to create your own Buffer-like classes. No other properties are
set, so the user will need to keep track of other necessary information (e.g.
`length` of the allocation).
// { '0': 0, '1': 0.1, '2': 0.2 }
-## smalloc.copyOnto(source, sourceStart, dest, destStart, copyLength);
+### smalloc.copyOnto(source, sourceStart, dest, destStart, copyLength);
-* `source` Object with external array allocation
-* `sourceStart` Position to begin copying from
-* `dest` Object with external array allocation
-* `destStart` Position to begin copying onto
-* `copyLength` Length of copy
+* `source` {Object} with external array allocation
+* `sourceStart` {Number} Position to begin copying from
+* `dest` {Object} with external array allocation
+* `destStart` {Number} Position to begin copying onto
+* `copyLength` {Number} Length of copy
Copy memory from one external array allocation to another. No arguments are
optional, and any violation will throw.
`copyOnto` automatically detects the length of the allocation internally, so no
need to set any additional properties for this to work.
-## smalloc.dispose(obj)
+### smalloc.dispose(obj)
* `obj` Object
`dispose()` does not support Buffers, and will throw if passed.
-## smalloc.hasExternalData(obj)
+### smalloc.hasExternalData(obj)
* `obj` {Object}
Returns `true` if the `obj` has externally allocated memory.
-## smalloc.kMaxLength
+### smalloc.kMaxLength
Size of maximum allocation. This is also applicable to Buffer creation.
-## smalloc.Types
+### smalloc.Types
Enum of possible external array types. Contains:
* [child process stdin](child_process.html#child_process_child_stdin)
* [process.stdout][], [process.stderr][]
-#### writable.write(chunk[, encoding]\[, callback])
+#### writable.write(chunk[, encoding][, callback])
* `chunk` {String | Buffer} The data to write
* `encoding` {String} The encoding, if `chunk` is a String
Flush all data, buffered since `.cork()` call.
-#### writable.end([chunk]\[, encoding]\[, callback])
+#### writable.end([chunk][, encoding][, callback])
* `chunk` {String | Buffer} Optional data to write
* `encoding` {String} The encoding, if `chunk` is a String
All of the timer functions are globals. You do not need to `require()`
this module in order to use them.
-## setTimeout(callback, delay[, arg]\[, ...])
+## setTimeout(callback, delay[, arg][, ...])
To schedule execution of a one-time `callback` after `delay` milliseconds. Returns a
`timeoutObject` for possible use with `clearTimeout()`. Optionally you can
Prevents a timeout from triggering.
-## setInterval(callback, delay[, arg]\[, ...])
+## setInterval(callback, delay[, arg][, ...])
To schedule the repeated execution of `callback` every `delay` milliseconds.
Returns a `intervalObject` for possible use with `clearInterval()`. Optionally
request the timer hold the program open. If the timer is already `ref`d calling
`ref` again will have no effect.
-## setImmediate(callback[, arg]\[, ...])
+## setImmediate(callback[, arg][, ...])
To schedule the "immediate" execution of `callback` after I/O events
callbacks and before `setTimeout` and `setInterval` . Returns an
## tls.connect(options[, callback])
-## tls.connect(port[, host]\[, options]\[, callback])
+## tls.connect(port[, host][, options][, callback])
Creates a new client connection to the given `port` and `host` (old API) or
`options.port` and `options.host`. (If `host` is omitted, it defaults to
<http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt>.
-## tls.createSecurePair([context]\[, isServer]\[, requestCert]\[, rejectUnauthorized])
+## tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized])
Stability: 0 - Deprecated. Use tls.TLSSocket instead.
certificates.
-### server.listen(port[, host]\[, callback])
+### server.listen(port[, host][, callback])
Begin accepting connections on the specified `port` and `host`. If the
`host` is omitted, the server will accept connections directed to any
The following methods are provided by the URL module:
-## url.parse(urlStr[, parseQueryString]\[, slashesDenoteHost])
+## url.parse(urlStr[, parseQueryString][, slashesDenoteHost])
Take a URL string, and return an object.
separate process.
-## vm.runInNewContext(code[, sandbox]\[, options])
+## vm.runInNewContext(code[, sandbox][, options])
`vm.runInNewContext` compiles `code`, contextifies `sandbox` if passed or
creates a new contextified sandbox if it's omitted, and then runs the code with
requires a separate process.
-### script.runInNewContext([sandbox]\[, options])
+### script.runInNewContext([sandbox][, options])
Similar to `vm.runInNewContext` but a method of a precompiled `Script` object.
`script.runInNewContext` contextifies `sandbox` if passed or creates a new
}
-// textRaw = "someobject.someMethod(a, [b=100], [c])"
+// textRaw = "someobject.someMethod(a[, b=100][, c])"
function parseSignature(text, sig) {
var params = text.match(paramExpr);
if (!params) return;
params = params[1];
- // the ] is irrelevant. [ indicates optionalness.
- params = params.replace(/\]/g, '');
+ // the [ is irrelevant. ] indicates optionalness.
+ params = params.replace(/\[/g, '');
params = params.split(/,/)
params.forEach(function(p, i, _) {
p = p.trim();
var optional = false;
var def;
// [foo] -> optional
- if (p.charAt(0) === '[') {
+ if (p.charAt(p.length - 1) === ']') {
optional = true;
- p = p.substr(1);
+ p = p.substr(0, p.length - 1);
+ p = p.trim();
}
var eq = p.indexOf('=');
if (eq !== -1) {