Documentation incorrectly used bracket notation for optional parameters.
This caused inconsistencies in usage because of examples like the
following:
fs.write(fd, data[, position[, encoding]], callback)
This simply fixes all uses of bracket notation in documentation.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Throws an exception that displays the values for `actual` and `expected` separated by the provided operator.
-## assert(value, message), assert.ok(value, [message])
+## assert(value, message), assert.ok(value[, message])
Tests if value is truthy, it is equivalent to `assert.equal(true, !!value, message);`
-## assert.equal(actual, expected, [message])
+## assert.equal(actual, expected[, message])
Tests shallow, coercive equality with the equal comparison operator ( `==` ).
-## assert.notEqual(actual, expected, [message])
+## assert.notEqual(actual, expected[, message])
Tests shallow, coercive non-equality with the not equal comparison operator ( `!=` ).
-## assert.deepEqual(actual, expected, [message])
+## assert.deepEqual(actual, expected[, message])
Tests for deep equality.
-## assert.notDeepEqual(actual, expected, [message])
+## assert.notDeepEqual(actual, expected[, message])
Tests for any deep inequality.
-## assert.strictEqual(actual, expected, [message])
+## assert.strictEqual(actual, expected[, message])
Tests strict equality, as determined by the strict equality operator ( `===` )
-## assert.notStrictEqual(actual, expected, [message])
+## assert.notStrictEqual(actual, expected[, message])
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.
"unexpected error"
);
-## assert.doesNotThrow(block, [message])
+## assert.doesNotThrow(block[, message])
Expects `block` not to throw an error, see `assert.throws` for details.
Allocates a new buffer using an `array` of octets.
-### new Buffer(str, [encoding])
+### new Buffer(str[, encoding])
* `str` String - string to encode.
* `encoding` String - encoding to use, Optional.
Tests if `obj` is a `Buffer`.
-### Class Method: Buffer.byteLength(string, [encoding])
+### Class Method: Buffer.byteLength(string[, encoding])
* `string` String
* `encoding` String, Optional, Default: 'utf8'
// ½ + ¼ = ¾: 9 characters, 12 bytes
-### Class Method: Buffer.concat(list, [totalLength])
+### Class Method: Buffer.concat(list[, totalLength])
* `list` {Array} List of Buffer objects to concat
* `totalLength` {Number} Total length of the buffers when concatenated
// 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`
// abc
// !bc
-### buf.readUInt8(offset, [noAssert])
+### buf.readUInt8(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
// 0x23
// 0x42
-### buf.readUInt16LE(offset, [noAssert])
-### buf.readUInt16BE(offset, [noAssert])
+### buf.readUInt16LE(offset[, noAssert])
+### buf.readUInt16BE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
// 0x2342
// 0x4223
-### buf.readUInt32LE(offset, [noAssert])
-### buf.readUInt32BE(offset, [noAssert])
+### buf.readUInt32LE(offset[, noAssert])
+### buf.readUInt32BE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
// 0x03042342
// 0x42230403
-### buf.readInt8(offset, [noAssert])
+### buf.readInt8(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
Works as `buffer.readUInt8`, except buffer contents are treated as two's
complement signed values.
-### buf.readInt16LE(offset, [noAssert])
-### buf.readInt16BE(offset, [noAssert])
+### buf.readInt16LE(offset[, noAssert])
+### buf.readInt16BE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
Works as `buffer.readUInt16*`, except buffer contents are treated as two's
complement signed values.
-### buf.readInt32LE(offset, [noAssert])
-### buf.readInt32BE(offset, [noAssert])
+### buf.readInt32LE(offset[, noAssert])
+### buf.readInt32BE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
Works as `buffer.readUInt32*`, except buffer contents are treated as two's
complement signed values.
-### buf.readFloatLE(offset, [noAssert])
-### buf.readFloatBE(offset, [noAssert])
+### buf.readFloatLE(offset[, noAssert])
+### buf.readFloatBE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
// 0x01
-### buf.readDoubleLE(offset, [noAssert])
-### buf.readDoubleBE(offset, [noAssert])
+### buf.readDoubleLE(offset[, noAssert])
+### buf.readDoubleBE(offset[, noAssert])
* `offset` Number
* `noAssert` Boolean, Optional, Default: false
// 0.3333333333333333
-### buf.writeUInt8(value, offset, [noAssert])
+### buf.writeUInt8(value, offset[, noAssert])
* `value` Number
* `offset` Number
// <Buffer 03 04 23 42>
-### buf.writeUInt16LE(value, offset, [noAssert])
-### buf.writeUInt16BE(value, offset, [noAssert])
+### buf.writeUInt16LE(value, offset[, noAssert])
+### buf.writeUInt16BE(value, offset[, noAssert])
* `value` Number
* `offset` Number
// <Buffer de ad be ef>
// <Buffer ad de ef be>
-### buf.writeUInt32LE(value, offset, [noAssert])
-### buf.writeUInt32BE(value, offset, [noAssert])
+### buf.writeUInt32LE(value, offset[, noAssert])
+### buf.writeUInt32BE(value, offset[, noAssert])
* `value` Number
* `offset` Number
// <Buffer fe ed fa ce>
// <Buffer ce fa ed fe>
-### buf.writeInt8(value, offset, [noAssert])
+### buf.writeInt8(value, offset[, noAssert])
* `value` Number
* `offset` Number
Works as `buffer.writeUInt8`, except value is written out as a two's complement
signed integer into `buffer`.
-### buf.writeInt16LE(value, offset, [noAssert])
-### buf.writeInt16BE(value, offset, [noAssert])
+### buf.writeInt16LE(value, offset[, noAssert])
+### buf.writeInt16BE(value, offset[, noAssert])
* `value` Number
* `offset` Number
Works as `buffer.writeUInt16*`, except value is written out as a two's
complement signed integer into `buffer`.
-### buf.writeInt32LE(value, offset, [noAssert])
-### buf.writeInt32BE(value, offset, [noAssert])
+### buf.writeInt32LE(value, offset[, noAssert])
+### buf.writeInt32BE(value, offset[, noAssert])
* `value` Number
* `offset` Number
Works as `buffer.writeUInt32*`, except value is written out as a two's
complement signed integer into `buffer`.
-### buf.writeFloatLE(value, offset, [noAssert])
-### buf.writeFloatBE(value, offset, [noAssert])
+### buf.writeFloatLE(value, offset[, noAssert])
+### buf.writeFloatBE(value, offset[, noAssert])
* `value` Number
* `offset` Number
// <Buffer 4f 4a fe bb>
// <Buffer bb fe 4a 4f>
-### buf.writeDoubleLE(value, offset, [noAssert])
-### buf.writeDoubleBE(value, offset, [noAssert])
+### buf.writeDoubleLE(value, offset[, noAssert])
+### buf.writeDoubleBE(value, offset[, noAssert])
* `value` Number
* `offset` Number
// <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
See `kill(2)`
-### child.send(message, [sendHandle])
+### child.send(message[, sendHandle])
* `message` {Object}
* `sendHandle` {Handle object}
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
See also: `child_process.exec()` and `child_process.fork()`
-### child_process.exec(command, [options], callback)
+### child_process.exec(command[, options], callback)
* `command` {String} The command to run, with space-separated arguments
* `options` {Object}
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
[`child_process.spawnSync`](#child_process_child_process_spawnsync_command_args_options)
-### child_process.execSync(command, [options])
+### child_process.execSync(command[, options])
* `command` {String} The command to run
* `options` {Object}
// kill worker
worker.kill();
-### worker.send(message, [sendHandle])
+### worker.send(message[, sendHandle])
* `message` {Object}
* `sendHandle` {Handle object}
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`.
-## console.dir(obj, [options])
+## console.dir(obj[, options])
Uses `util.inspect` on `obj` and prints resulting string to stdout. This function
bypasses any custom `inspect()` function on `obj`. An optional *options* object
console.timeEnd('100-elements');
// prints 100-elements: 262ms
-## console.trace(message, [...])
+## console.trace(message[, ...])
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...)`.
decipher, sign and verify methods.
-## crypto.setEngine(engine, [flags])
+## crypto.setEngine(engine[, flags])
Load and set engine for some/all OpenSSL functions (selected by flags).
Returned by `crypto.createHash`.
-### hash.update(data, [input_encoding])
+### hash.update(data[, input_encoding])
Updates the hash content with the given `data`, the encoding of which
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
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
Updates the sign object with data. This can be called many times
with new data as it is streamed.
-### sign.sign(private_key, [output_format])
+### sign.sign(private_key[, output_format])
Calculates the signature on all the updated data passed through the
sign.
Updates the verifier object with data. This can be called many times
with new data as it is streamed.
-### verifier.verify(object, signature, [signature_format])
+### verifier.verify(object, signature[, signature_format])
Verifies the signed data by using the `object` and `signature`.
`object` is a string containing a PEM encoded object, which can be
Note: `verifier` object can not be used after `verify()` method has been
called.
-## crypto.createDiffieHellman(prime_length, [generator])
+## crypto.createDiffieHellman(prime_length[, generator])
Creates a Diffie-Hellman key exchange object and generates a prime of
`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
which can be `'binary'`, `'hex'`, or `'base64'`. If no encoding is
provided, then a buffer is returned.
-### diffieHellman.setPublicKey(public_key, [encoding])
+### diffieHellman.setPublicKey(public_key[, encoding])
Sets the Diffie-Hellman public key. Key encoding can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
expected.
-### diffieHellman.setPrivateKey(private_key, [encoding])
+### diffieHellman.setPrivateKey(private_key[, encoding])
Sets the Diffie-Hellman private key. Key encoding can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
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
which can be `'binary'`, `'hex'`, or `'base64'`. If no encoding is
provided, then a buffer is returned.
-### ECDH.setPublicKey(public_key, [encoding])
+### ECDH.setPublicKey(public_key[, encoding])
Sets the EC Diffie-Hellman public key. Key encoding can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
expected.
-### ECDH.setPrivateKey(private_key, [encoding])
+### ECDH.setPrivateKey(private_key[, encoding])
Sets the EC Diffie-Hellman private key. Key encoding can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
/* alice_secret and bob_secret should be the same */
console.log(alice_secret == bob_secret);
-## crypto.pbkdf2(password, salt, iterations, keylen, [digest], callback)
+## crypto.pbkdf2(password, salt, iterations, keylen[, digest], callback)
Asynchronous PBKDF2 function. Applies the selected HMAC digest function
(default: SHA1) to derive a key of the requested length from the password,
You can get a list of supported digest functions with
[crypto.getHashes()](#crypto_crypto_gethashes).
-## crypto.pbkdf2Sync(password, salt, iterations, keylen, [digest])
+## crypto.pbkdf2Sync(password, salt, iterations, keylen[, digest])
Synchronous PBKDF2 function. Returns derivedKey or throws error.
-## crypto.randomBytes(size, [callback])
+## crypto.randomBytes(size[, callback])
Generates cryptographically strong pseudo-random data. Usage:
`crypto.randomBytes` without callback will not block even if all entropy sources
are drained.
-## crypto.pseudoRandomBytes(size, [callback])
+## crypto.pseudoRandomBytes(size[, callback])
Generates *non*-cryptographically strong pseudo-random data. The data
returned will be unique if it is sufficiently long, but is not
});
-## dgram.createSocket(type, [callback])
-## dgram.createSocket(options, [callback])
+## dgram.createSocket(type[, callback])
+## dgram.createSocket(options[, callback])
* `type` String. Either 'udp4' or 'udp6'
* `options` Object. Should contain a `type` property and could contain
Emitted when an error occurs.
-### socket.send(buf, offset, length, port, address, [callback])
+### socket.send(buf, offset, length, port, address[, callback])
* `buf` Buffer object or string. Message to be sent
* `offset` Integer. Offset in the buffer where the message starts.
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
// server listening 0.0.0.0:41234
-### socket.bind(options, [callback])
+### socket.bind(options[, callback])
* `options` {Object} - Required. Supports the following properties:
* `port` {Number} - Required.
Sets or clears the `IP_MULTICAST_LOOP` socket option. When this option is set, multicast
packets will also be received on the local interface.
-### socket.addMembership(multicastAddress, [multicastInterface])
+### socket.addMembership(multicastAddress[, multicastInterface])
* `multicastAddress` String
* `multicastInterface` String, Optional
If `multicastInterface` is not specified, the OS will try to add membership to all valid
interfaces.
-### socket.dropMembership(multicastAddress, [multicastInterface])
+### socket.dropMembership(multicastAddress[, multicastInterface])
* `multicastAddress` String
* `multicastInterface` String, Optional
});
});
-## dns.lookup(hostname, [options], callback)
+## dns.lookup(hostname[, options], callback)
Resolves a hostname (e.g. `'google.com'`) into the first found A (IPv4) or
AAAA (IPv6) record. `options` can be an object or integer. If `options` is
On error, `err` is an `Error` object, where `err.code` is the error code.
-## dns.resolve(hostname, [rrtype], callback)
+## dns.resolve(hostname[, rrtype], callback)
Resolves a hostname (e.g. `'google.com'`) into an array of the record types
specified by rrtype.
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.
Synchronous link(2).
-## fs.symlink(srcpath, dstpath, [type], callback)
+## fs.symlink(srcpath, dstpath[, type], callback)
Asynchronous symlink(2). No arguments other than a possible exception are given
to the completion callback.
Note that Windows junction points require the destination path to be absolute. When using
`'junction'`, the `destination` argument will automatically be normalized to absolute path.
-## fs.symlinkSync(srcpath, dstpath, [type])
+## fs.symlinkSync(srcpath, dstpath[, type])
Synchronous symlink(2).
Synchronous readlink(2). Returns the symbolic link's string value.
-## fs.realpath(path, [cache], callback)
+## fs.realpath(path[, cache], callback)
Asynchronous realpath(2). The `callback` gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths. `cache` is an
console.log(resolvedPath);
});
-## fs.realpathSync(path, [cache])
+## fs.realpathSync(path[, cache])
Synchronous realpath(2). Returns the resolved 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).
Synchronous close(2).
-## fs.open(path, flags, [mode], callback)
+## fs.open(path, flags[, mode], callback)
Asynchronous file open. See open(2). `flags` can be:
The kernel ignores the position argument and always appends the data to
the end of the file.
-## fs.openSync(path, flags, [mode])
+## fs.openSync(path, flags[, mode])
Synchronous version of `fs.open()`.
Synchronous version of `fs.read`. Returns the number of `bytesRead`.
-## fs.readFile(filename, [options], callback)
+## fs.readFile(filename[, options], callback)
* `filename` {String}
* `options` {Object}
If no encoding is specified, then the raw buffer is returned.
-## fs.readFileSync(filename, [options])
+## fs.readFileSync(filename[, options])
Synchronous version of `fs.readFile`. Returns the contents of the `filename`.
string. Otherwise it returns a buffer.
-## fs.writeFile(filename, data, [options], callback)
+## fs.writeFile(filename, data[, options], callback)
* `filename` {String}
* `data` {String | Buffer}
console.log('It\'s saved!');
});
-## fs.writeFileSync(filename, data, [options])
+## fs.writeFileSync(filename, data[, options])
The synchronous version of `fs.writeFile`.
-## fs.appendFile(filename, data, [options], callback)
+## fs.appendFile(filename, data[, options], callback)
* `filename` {String}
* `data` {String | Buffer}
console.log('The "data to append" was appended to file!');
});
-## fs.appendFileSync(filename, data, [options])
+## fs.appendFileSync(filename, data[, options])
The synchronous version of `fs.appendFile`.
-## fs.watchFile(filename, [options], listener)
+## fs.watchFile(filename[, options], listener)
Stability: 2 - Unstable. Use fs.watch instead, if possible.
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, [listener])
+## fs.unwatchFile(filename[, listener])
Stability: 2 - Unstable. Use fs.watch instead, if possible.
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.
systems. Note that as of v0.12, `ctime` is not "creation time", and
on Unix systems, it never was.
-## fs.createReadStream(path, [options])
+## fs.createReadStream(path[, options])
Returns a new ReadStream object (See `Readable Stream`).
Emitted when the ReadStream's file is opened.
-## fs.createWriteStream(path, [options])
+## fs.createWriteStream(path[, options])
Returns a new WriteStream object (See `Writable Stream`).
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
a listener for the ['listening'][] event. See also [net.Server.listen(port)][].
-### server.listen(path, [callback])
+### server.listen(path[, callback])
Start a UNIX socket server listening for connections on the given `path`.
a listener for the ['listening'][] event. See also [net.Server.listen(path)][].
-### server.listen(handle, [callback])
+### server.listen(handle[, callback])
* `handle` {Object}
* `callback` {Function}
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.removeHeader("Content-Encoding");
-### response.write(chunk, [encoding])
+### response.write(chunk[, encoding])
If this method is called and [response.writeHead()][] has not been called,
it will switch to implicit header mode and flush the implicit 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.
followed by `response.end()`.
-## http.request(options, [callback])
+## http.request(options[, callback])
Node maintains several connections per server to make HTTP requests.
This function allows one to transparently issue requests.
* Sending an Authorization header will override using the `auth` option
to compute basic authentication.
-## http.get(options, [callback])
+## http.get(options[, callback])
Since most requests are GET requests without bodies, Node provides this
convenience method. The only difference between this method and `http.request()`
data isn't sent until possibly much later. `request.flush()` lets you bypass
the optimization and kickstart the request.
-### request.write(chunk, [encoding])
+### request.write(chunk[, encoding])
Sends a chunk of the body. By calling this method
many times, the user can stream a request body to a
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
Aborts a request. (New since v0.3.8.)
-### request.setTimeout(timeout, [callback])
+### request.setTimeout(timeout[, callback])
Once a socket is assigned to this request and is connected
[socket.setTimeout()][] will be called.
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.
See [http.Server#timeout][].
-## https.createServer(options, [requestListener])
+## https.createServer(options[, requestListener])
Returns a new HTTPS web server object. The `options` is similar to
[tls.createServer()][]. The `requestListener` is a function which is
}).listen(8000);
-### server.listen(port, [host], [backlog], [callback])
-### server.listen(path, [callback])
-### server.listen(handle, [callback])
+### server.listen(port[, host]\[, backlog]\[, callback])
+### server.listen(path[, callback])
+### server.listen(handle[, callback])
See [http.listen()][] for details.
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.
nc -U /tmp/echo.sock
-## net.connect(options, [connectionListener])
-## net.createConnection(options, [connectionListener])
+## net.connect(options[, connectionListener])
+## net.createConnection(options[, connectionListener])
A factory method, which returns a new ['net.Socket'](#net_class_net_socket)
and connects to the supplied address and port.
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.
Is a factory method which returns a new ['net.Socket'](#net_class_net_socket).
-## 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
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
(Note: All sockets in Node set `SO_REUSEADDR` already)
-### server.listen(path, [callback])
+### server.listen(path[, callback])
* `path` {String}
* `callback` {Function}
net.createServer().listen(
path.join('\\\\?\\pipe', process.cwd(), 'myctl'))
-### server.listen(handle, [callback])
+### server.listen(handle[, callback])
* `handle` {Object}
* `callback` {Function}
the last parameter `callback` will be added as an listener for the
['listening'][] event.
-### server.listen(options, [callback])
+### server.listen(options[, callback])
* `options` {Object} - Required. Supports the following properties:
* `port` {Number} - Optional.
socket (NOTE: Works only when `fd` is passed).
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,
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.
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.
`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.
// 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.
target_arch: 'x64',
v8_use_snapshot: 'true' } }
-## 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
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 (`'='`)
Closes the `Interface` instance, relinquishing control on the `input` and
`output` streams. The "close" event will also be emitted.
-### rl.write(data, [key])
+### rl.write(data[, key])
Writes `data` to `output` stream. `key` is an object literal to represent a key
sequence; available if the terminal is a TTY.
readable.isPaused() // === false
```
-#### readable.pipe(destination, [options])
+#### readable.pipe(destination[, options])
* `destination` {[Writable][] Stream} The destination for writing data
* `options` {Object} Pipe options
* [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
becomes available. There is no need, for example to "wait" until
`size` bytes are available before calling [`stream.push(chunk)`][].
-#### readable.push(chunk, [encoding])
+#### readable.push(chunk[, encoding])
* `chunk` {Buffer | null | String} Chunk of data to push into the read queue
* `encoding` {String} Encoding of String chunks. Must be a valid
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
console.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...]
-## tls.createServer(options, [secureConnectionListener])
+## tls.createServer(options[, secureConnectionListener])
Creates a new [tls.Server][]. The `connectionListener` argument is
automatically set as a listener for the [secureConnection][] event. The
openssl s_client -connect 127.0.0.1:8000
-## tls.connect(options, [callback])
-## tls.connect(port, [host], [options], [callback])
+## tls.connect(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.
You may separate multiple `NODE_DEBUG` environment variables with a
comma. For example, `NODE_DEBUG=fs,net,tls`.
-## util.format(format, [...])
+## util.format(format[, ...])
Returns a formatted string using the first argument as a `printf`-like format.
require('util').log('Timestamped message.');
-## util.inspect(object, [options])
+## util.inspect(object[, options])
Return a string representation of `object`, which is useful for debugging.
Deprecated predecessor of `console.log`.
-## util.pump(readableStream, writableStream, [callback])
+## util.pump(readableStream, writableStream[, callback])
Stability: 0 - Deprecated: Use readableStream.pipe(writableStream)
JavaScript code can be compiled and run immediately or compiled, saved, and run
later.
-## vm.runInThisContext(code, [options])
+## vm.runInThisContext(code[, options])
`vm.runInThisContext()` compiles `code`, runs it and returns the result. Running
code does not have access to local scope, but does have access to the current
`vm.createContext` on it.
-## vm.runInContext(code, contextifiedSandbox, [options])
+## vm.runInContext(code, contextifiedSandbox[, options])
`vm.runInContext` compiles `code`, then runs it in `contextifiedSandbox` and
returns the result. Running code does not have access to local scope. The
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
execution. If execution is terminated, an `Error` will be thrown.
-### script.runInContext(contextifiedSandbox, [options])
+### script.runInContext(contextifiedSandbox[, options])
Similar to `vm.runInContext` but a method of a precompiled `Script` object.
`script.runInContext` runs `script`'s compiled code in `contextifiedSandbox`
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
Every method has a `*Sync` counterpart, which accept the same arguments, but
without a callback.
-## zlib.deflate(buf, [options], callback)
-## zlib.deflateSync(buf, [options])
+## zlib.deflate(buf[, options], callback)
+## zlib.deflateSync(buf[, options])
Compress a string with Deflate.
-## zlib.deflateRaw(buf, [options], callback)
-## zlib.deflateRawSync(buf, [options])
+## zlib.deflateRaw(buf[, options], callback)
+## zlib.deflateRawSync(buf[, options])
Compress a string with DeflateRaw.
-## zlib.gzip(buf, [options], callback)
-## zlib.gzipSync(buf, [options])
+## zlib.gzip(buf[, options], callback)
+## zlib.gzipSync(buf[, options])
Compress a string with Gzip.
-## zlib.gunzip(buf, [options], callback)
-## zlib.gunzipSync(buf, [options])
+## zlib.gunzip(buf[, options], callback)
+## zlib.gunzipSync(buf[, options])
Decompress a raw Buffer with Gunzip.
-## zlib.inflate(buf, [options], callback)
-## zlib.inflateSync(buf, [options])
+## zlib.inflate(buf[, options], callback)
+## zlib.inflateSync(buf[, options])
Decompress a raw Buffer with Inflate.
-## zlib.inflateRaw(buf, [options], callback)
-## zlib.inflateRawSync(buf, [options])
+## zlib.inflateRaw(buf[, options], callback)
+## zlib.inflateRawSync(buf[, options])
Decompress a raw Buffer with InflateRaw.
-## zlib.unzip(buf, [options], callback)
-## zlib.unzipSync(buf, [options])
+## zlib.unzip(buf[, options], callback)
+## zlib.unzipSync(buf[, options])
Decompress a raw Buffer with Unzip.