Fixes #2106.
Allocates a new buffer using an `array` of octets.
-### new Buffer(str, encoding='utf8')
+### new Buffer(str, [encoding])
Allocates a new buffer containing the given `str`.
+`encoding` defaults to `'utf8'`.
-### buffer.write(string, offset=0, length=buffer.length-offset, encoding='utf8')
+### buffer.write(string, [offset], [length], [encoding])
-Writes `string` to the buffer at `offset` using the given encoding. `length` is
+Writes `string` to the buffer at `offset` using the given encoding.
+`offset` defaults to `0`, `encoding` defaults to `'utf8'`. `length` is
the number of bytes to write. Returns number of octets written. If `buffer` did
not contain enough space to fit the entire string, it will write a partial
-amount of the string. The method will not write partial characters.
-
-Example: write a utf8 string into a buffer, then print it
+amount of the string. `length` defaults to `buffer.length - offset`.
+The method will not write partial characters.
buf = new Buffer(256);
len = buf.write('\u00bd + \u00bc = \u00be', 0);
next time `buf.write()` is called.
-### buffer.toString(encoding, start=0, end=buffer.length)
+### buffer.toString(encoding, [start], [end])
Decodes and returns a string from buffer data encoded with `encoding`
-beginning at `start` and ending at `end`.
+(defaults to `'utf8'`) beginning at `start` (defaults to `0`) and ending at
+`end` (defaults to `buffer.length`).
See `buffer.write()` example, above.
Tests if `obj` is a `Buffer`.
-### Buffer.byteLength(string, encoding='utf8')
+### Buffer.byteLength(string, [encoding])
-Gives the actual byte length of a string. This is not the same as
-`String.prototype.length` since that returns the number of *characters* in a
-string.
+Gives the actual byte length of a string. `encoding` defaults to `'utf8'`.
+This is not the same as `String.prototype.length` since that returns the
+number of *characters* in a string.
Example:
// 1234
// 1234
-### buffer.copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+### buffer.copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd])
Does copy between buffers. The source and target regions can be overlapped.
+`targetStart` and `sourceStart` default to `0`.
+`sourceEnd` defaults to `buffer.length`.
Example: build two Buffers, then copy `buf1` from byte 16 through byte 19
into `buf2`, starting at the 8th byte in `buf2`.
// !!!!!!!!qrst!!!!!!!!!!!!!
-### buffer.slice(start, end=buffer.length)
+### buffer.slice([start], [end])
-Returns a new buffer which references the
-same memory as the old, but offset and cropped by the `start` and `end`
-indexes.
+Returns a new buffer which references the same memory as the old, but offset
+and cropped by the `start` (defaults to `0`) and `end` (defaults to
+`buffer.length`) indexes.
**Modifying the new buffer slice will modify memory in the original buffer!**
// abc
// !bc
-### buffer.readUInt8(offset, noAssert=false)
+### buffer.readUInt8(offset, [noAssert])
Reads an unsigned 8 bit integer from the buffer at the specified offset.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Example:
// 0x23
// 0x42
-### buffer.readUInt16LE(offset, noAssert=false)
-### buffer.readUInt16BE(offset, noAssert=false)
+### buffer.readUInt16LE(offset, [noAssert])
+### buffer.readUInt16BE(offset, [noAssert])
Reads an unsigned 16 bit integer from the buffer at the specified offset with
specified endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Example:
// 0x2342
// 0x4223
-### buffer.readUInt32LE(offset, noAssert=false)
-### buffer.readUInt32BE(offset, noAssert=false)
+### buffer.readUInt32LE(offset, [noAssert])
+### buffer.readUInt32BE(offset, [noAssert])
Reads an unsigned 32 bit integer from the buffer at the specified offset with
specified endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Example:
// 0x03042342
// 0x42230403
-### buffer.readInt8(offset, noAssert=false)
+### buffer.readInt8(offset, [noAssert])
Reads a signed 8 bit integer from the buffer at the specified offset.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Works as `buffer.readUInt8`, except buffer contents are treated as two's
complement signed values.
-### buffer.readInt16LE(offset, noAssert=false)
-### buffer.readInt16BE(offset, noAssert=false)
+### buffer.readInt16LE(offset, [noAssert])
+### buffer.readInt16BE(offset, [noAssert])
Reads a signed 16 bit integer from the buffer at the specified offset with
specified endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Works as `buffer.readUInt16*`, except buffer contents are treated as two's
complement signed values.
-### buffer.readInt32LE(offset, noAssert=false)
-### buffer.readInt32BE(offset, noAssert=false)
+### buffer.readInt32LE(offset, [noAssert])
+### buffer.readInt32BE(offset, [noAssert])
Reads a signed 32 bit integer from the buffer at the specified offset with
specified endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Works as `buffer.readUInt32*`, except buffer contents are treated as two's
complement signed values.
-### buffer.readFloatLE(offset, noAssert=false)
-### buffer.readFloatBE(offset, noAssert=false)
+### buffer.readFloatLE(offset, [noAssert])
+### buffer.readFloatBE(offset, [noAssert])
Reads a 32 bit float from the buffer at the specified offset with specified
endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Example:
// 0x01
-### buffer.readDoubleLE(offset, noAssert=false)
-### buffer.readDoubleBE(offset, noAssert=false)
+### buffer.readDoubleLE(offset, [noAssert])
+### buffer.readDoubleBE(offset, [noAssert])
Reads a 64 bit double from the buffer at the specified offset with specified
endian format.
Set `noAssert` to true to skip validation of `offset`. This means that `offset`
-may be beyond the end of the buffer.
+may be beyond the end of the buffer. Defaults to `false`.
Example:
// 0.3333333333333333
-### buffer.writeUInt8(value, offset, noAssert=false)
+### buffer.writeUInt8(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset. Note, `value` must be a
valid unsigned 8 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Example:
// <Buffer 03 04 23 42>
-### buffer.writeUInt16LE(value, offset, noAssert=false)
-### buffer.writeUInt16BE(value, offset, noAssert=false)
+### buffer.writeUInt16LE(value, offset, [noAssert])
+### buffer.writeUInt16BE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid unsigned 16 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Example:
// <Buffer de ad be ef>
// <Buffer ad de ef be>
-### buffer.writeUInt32LE(value, offset, noAssert=false)
-### buffer.writeUInt32BE(value, offset, noAssert=false)
+### buffer.writeUInt32LE(value, offset, [noAssert])
+### buffer.writeUInt32BE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid unsigned 32 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Example:
// <Buffer fe ed fa ce>
// <Buffer ce fa ed fe>
-### buffer.writeInt8(value, offset, noAssert=false)
+### buffer.writeInt8(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset. Note, `value` must be a
valid signed 8 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Works as `buffer.writeUInt8`, except value is written out as a two's complement
signed integer into `buffer`.
-### buffer.writeInt16LE(value, offset, noAssert=false)
-### buffer.writeInt16BE(value, offset, noAssert=false)
+### buffer.writeInt16LE(value, offset, [noAssert])
+### buffer.writeInt16BE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid signed 16 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Works as `buffer.writeUInt16*`, except value is written out as a two's
complement signed integer into `buffer`.
-### buffer.writeInt32LE(value, offset, noAssert=false)
-### buffer.writeInt32BE(value, offset, noAssert=false)
+### buffer.writeInt32LE(value, offset, [noAssert])
+### buffer.writeInt32BE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid signed 32 bit integer.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Works as `buffer.writeUInt32*`, except value is written out as a two's
complement signed integer into `buffer`.
-### buffer.writeFloatLE(value, offset, noAssert=false)
-### buffer.writeFloatBE(value, offset, noAssert=false)
+### buffer.writeFloatLE(value, offset, [noAssert])
+### buffer.writeFloatBE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid 32 bit float.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Example:
// <Buffer 4f 4a fe bb>
// <Buffer bb fe 4a 4f>
-### buffer.writeDoubleLE(value, offset, noAssert=false)
-### buffer.writeDoubleBE(value, offset, noAssert=false)
+### buffer.writeDoubleLE(value, offset, [noAssert])
+### buffer.writeDoubleBE(value, offset, [noAssert])
Writes `value` to the buffer at the specified offset with specified endian
format. Note, `value` must be a valid 64 bit double.
Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
beyond the end of the buffer leading to the values being silently dropped. This
-should not be used unless you are certain of correctness.
+should not be used unless you are certain of correctness. Defaults to `false`.
Example:
// <Buffer 43 eb d5 b7 dd f9 5f d7>
// <Buffer d7 5f f9 dd b7 d5 eb 43>
-### buffer.fill(value, offset=0, end=buffer.length)
+### buffer.fill(value, [offset], [end])
-Fills the buffer with the specified value. If the offset and end are not
-given it will fill the entire buffer.
+Fills the buffer with the specified value. If the `offset` (defaults to `0`)
+and `end` (defaults to `buffer.length`) are not given it will fill the entire
+buffer.
var b = new Buffer(50);
b.fill("h");
grep.stdin.end();
-### child_process.spawn(command, args=[], [options])
+### child_process.spawn(command, [args], [options])
Launches a new process with the given `command`, with command line arguments in `args`.
If omitted, `args` defaults to an empty Array.
-### child.kill(signal='SIGTERM')
+### child.kill([signal])
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.
console.log(d + ' ' + filename);
});
-### hash.update(data, input_encoding='binary')
+### 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 `'binary'`.
+Defaults to `'binary'`.
This can be called many times with new data as it is streamed.
-### hash.digest(encoding='binary')
+### hash.digest([encoding])
Calculates the digest of all of the passed data to be hashed.
The `encoding` can be `'hex'`, `'binary'` or `'base64'`.
+Defaults to `'binary'`.
Note: `hash` object can not be used after `digest()` method been called.
Update the hmac content with the given `data`.
This can be called many times with new data as it is streamed.
-### hmac.digest(encoding='binary')
+### hmac.digest([encoding])
Calculates the digest of all of the passed data to the hmac.
The `encoding` can be `'hex'`, `'binary'` or `'base64'`.
+Defaults to `'binary'`.
Note: `hmac` object can not be used after `digest()` method been called.
algorithm. `iv` is an Initialization vector. `key` and `iv` must be `'binary'`
encoded string (See the [Buffers](buffers.html) for more information).
-### cipher.update(data, input_encoding='binary', output_encoding='binary')
+### 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'`. The `output_encoding` specifies
-the output format of the enciphered data, and can be `'binary'`, `'base64'` or `'hex'`.
+Updates the cipher with `data`, the encoding of which is given in
+`input_encoding` and can be `'utf8'`, `'ascii'` or `'binary'`.
+Defaults to `'binary'`.
+
+The `output_encoding` specifies the output format of the enciphered data,
+and can be `'binary'`, `'base64'` or `'hex'`. Defaults to `'binary'`.
Returns the enciphered contents, and can be called many times with new data as it is streamed.
-### cipher.final(output_encoding='binary')
+### cipher.final([output_encoding])
-Returns any remaining enciphered contents, with `output_encoding` being one of: `'binary'`, `'base64'` or `'hex'`.
+Returns any remaining enciphered contents, with `output_encoding` being one of:
+`'binary'`, `'base64'` or `'hex'`. Defaults to `'binary'`.
Note: `cipher` object can not be used after `final()` method been called.
Creates and returns a decipher object, with the given algorithm, key and iv.
This is the mirror of the [createCipheriv()](#crypto.createCipheriv) above.
-### decipher.update(data, input_encoding='binary', output_encoding='binary')
+### decipher.update(data, [input_encoding], [output_encoding])
+
+Updates the decipher with `data`, which is encoded in `'binary'`, `'base64'`
+or `'hex'`. Defaults to `'binary'`.
-Updates the decipher with `data`, which is encoded in `'binary'`, `'base64'` or `'hex'`.
-The `output_decoding` specifies in what format to return the deciphered plaintext: `'binary'`, `'ascii'` or `'utf8'`.
+The `output_decoding` specifies in what format to return the deciphered
+plaintext: `'binary'`, `'ascii'` or `'utf8'`. Defaults to `'binary'`.
-### decipher.final(output_encoding='binary')
+### decipher.final([output_encoding])
Returns any remaining plaintext which is deciphered,
with `output_encoding` being one of: `'binary'`, `'ascii'` or `'utf8'`.
+Defaults to `'binary'`.
Note: `decipher` object can not be used after `final()` method been called.
Updates the signer object with data.
This can be called many times with new data as it is streamed.
-### signer.sign(private_key, output_format='binary')
+### signer.sign(private_key, [output_format])
Calculates the signature on all the updated data passed through the signer.
`private_key` is a string containing the PEM encoded private key for signing.
-Returns the signature in `output_format` which can be `'binary'`, `'hex'` or `'base64'`.
+Returns the signature in `output_format` which can be `'binary'`, `'hex'` or
+`'base64'`. Defaults to `'binary'`.
Note: `signer` object can not be used after `sign()` method been called.
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='binary')
+### 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 one of RSA public key,
DSA public key, or X.509 certificate. `signature` is the previously calculated
signature for the data, in the `signature_format` which can be `'binary'`,
-`'hex'` or `'base64'`.
+`'hex'` or `'base64'`. Defaults to `'binary'`.
Returns true or false depending on the validity of the signature for the data and public key.
Creates a Diffie-Hellman key exchange object and generates a prime of the
given bit length. The generator used is `2`.
-### crypto.createDiffieHellman(prime, encoding='binary')
+### crypto.createDiffieHellman(prime, [encoding])
Creates a Diffie-Hellman key exchange object using the supplied prime. The
generator used is `2`. Encoding can be `'binary'`, `'hex'`, or `'base64'`.
+Defaults to `'binary'`.
-### diffieHellman.generateKeys(encoding='binary')
+### diffieHellman.generateKeys([encoding])
Generates private and public Diffie-Hellman key values, and returns the
public key in the specified encoding. This key should be transferred to the
other party. Encoding can be `'binary'`, `'hex'`, or `'base64'`.
+Defaults to `'binary'`.
-### diffieHellman.computeSecret(other_public_key, input_encoding='binary', output_encoding=input_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 key is
interpreted using specified `input_encoding`, and secret is encoded using
specified `output_encoding`. Encodings can be `'binary'`, `'hex'`, or
-`'base64'`. If no output encoding is given, the input encoding is used as
-output encoding.
+`'base64'`. The input encoding defaults to `'binary'`.
+If no output encoding is given, the input encoding is used as output encoding.
-### diffieHellman.getPrime(encoding='binary')
+### diffieHellman.getPrime([encoding])
Returns the Diffie-Hellman prime in the specified encoding, which can be
-`'binary'`, `'hex'`, or `'base64'`.
+`'binary'`, `'hex'`, or `'base64'`. Defaults to `'binary'`.
-### diffieHellman.getGenerator(encoding='binary')
+### diffieHellman.getGenerator([encoding])
Returns the Diffie-Hellman prime in the specified encoding, which can be
-`'binary'`, `'hex'`, or `'base64'`.
+`'binary'`, `'hex'`, or `'base64'`. Defaults to `'binary'`.
-### diffieHellman.getPublicKey(encoding='binary')
+### diffieHellman.getPublicKey([encoding])
Returns the Diffie-Hellman public key in the specified encoding, which can
-be `'binary'`, `'hex'`, or `'base64'`.
+be `'binary'`, `'hex'`, or `'base64'`. Defaults to `'binary'`.
-### diffieHellman.getPrivateKey(encoding='binary')
+### diffieHellman.getPrivateKey([encoding])
Returns the Diffie-Hellman private key in the specified encoding, which can
-be `'binary'`, `'hex'`, or `'base64'`.
+be `'binary'`, `'hex'`, or `'base64'`. Defaults to `'binary'`.
-### diffieHellman.setPublicKey(public_key, encoding='binary')
+### diffieHellman.setPublicKey(public_key, [encoding])
Sets the Diffie-Hellman public key. Key encoding can be `'binary'`, `'hex'`,
-or `'base64'`.
+or `'base64'`. Defaults to `'binary'`.
-### diffieHellman.setPrivateKey(public_key, encoding='binary')
+### diffieHellman.setPrivateKey(public_key, [encoding])
-Sets the Diffie-Hellman private key. Key encoding can be `'binary'`, `'hex'`, or `'base64'`.
+Sets the Diffie-Hellman private key. Key encoding can be `'binary'`, `'hex'`,
+or `'base64'`. Defaults to `'binary'`.
### pbkdf2(password, salt, iterations, keylen, callback)
});
});
-### dns.lookup(domain, family=null, callback)
+### dns.lookup(domain, [family], callback)
Resolves a domain (e.g. `'google.com'`) into the first found A (IPv4) or
AAAA (IPv6) record.
+The `family` can be the integer `4` or `6`. Defaults to `null` that indicates
+both Ip v4 and v6 address family.
The callback has arguments `(err, address, family)`. The `address` argument
is a string representation of a IP v4 or v6 address. The `family` argument
necessarily the value initially passed to `lookup`).
-### dns.resolve(domain, rrtype='A', 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), `AAAA` (IPV6
-addresses), `MX` (mail exchange records), `TXT` (text records), `SRV` (SRV
-records), `PTR` (used for reverse IP lookups), `NS` (name server records)
-and `CNAME` (canonical name records).
+specified by rrtype. Valid rrtypes are `'A'` (IPV4 addresses, default),
+`'AAAA'` (IPV6 addresses), `'MX'` (mail exchange records), `'TXT'` (text
+records), `'SRV'` (SRV records), `'PTR'` (used for reverse IP lookups),
+`'NS'` (name server records) and `'CNAME'` (canonical name records).
The callback has arguments `(err, addresses)`. The type of each item
in `addresses` is determined by the record type, and described in the
Synchronous version of buffer-based `fs.write()`. Returns the number of bytes
written.
-### fs.writeSync(fd, str, position, encoding='utf8')
+### fs.writeSync(fd, str, position, [encoding])
-Synchronous version of string-based `fs.write()`. Returns the number of _bytes_
-written.
+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])
returns a buffer.
-### fs.writeFile(filename, data, encoding='utf8', [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
-`data` is a buffer.
+`data` is a buffer. It defaults to `'utf8'`.
Example:
console.log('It\'s saved!');
});
-### fs.writeFileSync(filename, data, encoding='utf8')
+### fs.writeFileSync(filename, data, [encoding])
The synchronous version of `fs.writeFile`.
`request.httpVersionMinor` is the second.
-### request.setEncoding(encoding=null)
+### request.setEncoding([encoding])
Set the encoding for the request body. Either `'utf8'` or `'binary'`. Defaults
to `null`, which means that the `'data'` event will emit a `Buffer` object..
response.removeHeader("Content-Encoding");
-### response.write(chunk, encoding='utf8')
+### 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.
the request contained 'Expect: 100-continue'. This is an instruction that
the client should send the request body.
-### request.write(chunk, encoding='utf8')
+### 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
The `chunk` argument should be an array of integers
or a string.
-The `encoding` argument is optional and only
-applies when `chunk` is a string.
+The `encoding` argument is optional and only applies when `chunk` is a string.
+Defaults to `'utf8'`.
### request.end([data], [encoding])
unsent, it will flush them to the stream. If the request is
chunked, this will send the terminating `'0\r\n\r\n'`.
-If `data` is specified, it is equivalent to calling `request.write(data, encoding)`
-followed by `request.end()`.
+If `data` is specified, it is equivalent to calling
+`request.write(data, encoding)` followed by `request.end()`.
### request.abort()
[socket.setTimeout(timeout, [callback])](net.html#socket.setTimeout)
will be called.
-### request.setNoDelay(noDelay=true)
+### request.setNoDelay([noDelay])
Once a socket is assigned to this request and is connected
[socket.setNoDelay(noDelay)](net.html#socket.setNoDelay)
will be called.
-### request.setSocketKeepAlive(enable=false, [initialDelay])
+### request.setSocketKeepAlive([enable], [initialDelay])
Once a socket is assigned to this request and is connected
[socket.setKeepAlive(enable, [initialDelay])](net.html#socket.setKeepAlive)
The response trailers object. Only populated after the 'end' event.
-### response.setEncoding(encoding=null)
+### response.setEncoding([encoding])
-Set the encoding for the response body. Either `'utf8'`, `'ascii'`, or `'base64'`.
-Defaults to `null`, which means that the `'data'` event will emit a `Buffer` object..
+Set the encoding for the response body. Either `'utf8'`, `'ascii'`, or
+`'base64'`. Defaults to `null`, which means that the `'data'` event will emit
+a `Buffer` object..
### response.pause()
"throttle" the data flows in their program with `pause()` and `resume()`.
-#### socket.setEncoding(encoding=null)
+#### socket.setEncoding([encoding])
Sets the encoding (either `'ascii'`, `'utf8'`, or `'base64'`) for data that is
-received.
+received. Defaults to `null`.
#### socket.setSecure()
The optional `callback` parameter will be added as a one time listener for the
`'timeout'` event.
-#### socket.setNoDelay(noDelay=true)
+#### socket.setNoDelay([noDelay])
Disables the Nagle algorithm. By default TCP connections use the Nagle
-algorithm, they buffer data before sending it off. Setting `noDelay` will
-immediately fire off data each time `socket.write()` is called.
+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=false, [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.
+`enable` defaults to `false`.
+
Set `initialDelay` (in milliseconds) to set the delay between the last
data packet received and the first keepalive probe. Setting 0 for
initialDelay will leave the value unchanged from the default
-(or previous) setting.
+(or previous) setting. Defaults to `0`.
#### socket.address()
An object containing the user environment. See environ(7).
-### process.exit(code=0)
+### process.exit([code])
Ends the process with the specified `code`. If omitted, exit uses the
'success' code `0`.
console.log('Prefix: ' + process.installPrefix);
-### process.kill(pid, signal='SIGTERM')
+### 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='=')
+### querystring.stringify(obj, [sep], [eq])
Serialize an object to a query string.
-Optionally override the default separator and assignment characters.
+Optionally override the default separator (`'&'`) and assignment (`'='`)
+characters.
Example:
// returns
'foo:bar;baz:qux'
-### querystring.parse(str, sep='&', eq='=')
+### querystring.parse(str, [sep], [eq])
Deserialize a query string to an object.
-Optionally override the default separator and assignment characters.
+Optionally override the default separator (`'&'`) and assignment (`'='`)
+characters.
Example:
alias node="env NODE_NO_READLINE=1 rlwrap node"
-### repl.start(prompt='> ', stream=process.stdin, eval=eval, useGlobal=false, ignoreUndefined=false)
+### repl.start([prompt], [stream], [eval], [useGlobal], [ignoreUndefined])
Starts a REPL with `prompt` as the prompt and `stream` for all I/O. `prompt`
is optional and defaults to `> `. `stream` is optional and defaults to
-`process.stdin`. `eval` is optional too and defaults to async wrapper for `eval`.
+`process.stdin`. `eval` is optional too and defaults to async wrapper for
+`eval()`.
If `useGlobal` is set to true, then the repl will use the global object,
-instead of running scripts in a separate context.
+instead of running scripts in a separate context. Defaults to `false`.
If `ignoreUndefined` is set to true, then the repl will not output return value
-of command if it's `undefined`.
+of command if it's `undefined`. Defaults to `false`.
You can use your own `eval` function if it has following signature:
A boolean that is `true` by default, but turns `false` after an `'error'`
occurred or `end()` / `destroy()` was called.
-### stream.write(string, encoding='utf8', [fd])
+### stream.write(string, [encoding], [fd])
Writes `string` with the given `encoding` to the stream. Returns `true` if
the string has been flushed to the kernel buffer. Returns `false` to
The following methods are provided by the URL module:
-### url.parse(urlStr, parseQueryString=false, slashesDenoteHost=false)
+### url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
Take a URL string, and return an object.
Pass `true` as the second argument to also parse
the query string using the `querystring` module.
+Defaults to `false`.
Pass `true` as the third argument to treat `//foo/bar` as
`{ host: 'foo', pathname: '/bar' }` rather than
-`{ pathname: '//foo/bar' }`.
+`{ pathname: '//foo/bar' }`. Defaults to `false`.
### url.format(urlObj)
require('util').log('Timestamped message.');
-### util.inspect(object, showHidden=false, depth=2, colors=false)
+### util.inspect(object, [showHidden], [depth], [colors])
Return a string representation of `object`, which is useful for debugging.
If `showHidden` is `true`, then the object's non-enumerable properties will be
-shown too.
+shown too. Defaults to `false`.
If `depth` is provided, it tells `inspect` how many times to recurse while
formatting the object. This is useful for inspecting large complicated objects.
in `null` for `depth`.
If `colors` is `true`, the output will be styled with ANSI color codes.
+Defaults to `false`.
Example of inspecting all properties of the `util` object: