EventEmitter.optHandlers.encoding() if it exists.
- DOCS
- - Fix examples using leading comma style. EG
- http://nodejs.org/docs/v0.3.1/api/fs.html#fs.stat
- anchor links next to each function, for easy linking.
EG <a href="#fs.stat">#</a>
The third argument is used to specify additional options, which defaults to:
- { cwd: undefined
- , env: process.env,
- , customFds: [-1, -1, -1]
- }
+ { cwd: undefined,
+ env: process.env,
+ customFds: [-1, -1, -1] }
`cwd` allows you to specify the working directory from which the process is spawned.
Use `env` to specify environment variables that will be visible to the new process.
There is a second optional argument to specify several options. The default options are
- { encoding: 'utf8'
- , timeout: 0
- , maxBuffer: 200*1024
- , killSignal: 'SIGTERM'
- , cwd: null
- , env: null
- }
+ { encoding: 'utf8',
+ timeout: 0,
+ maxBuffer: 200*1024,
+ killSignal: 'SIGTERM',
+ cwd: null,
+ env: null }
If `timeout` is greater than 0, then it will kill the child process
if it runs longer than `timeout` milliseconds. The child process is killed with
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
`stats` is a `fs.Stats` object. It looks like this:
- { dev: 2049
- , ino: 305352
- , mode: 16877
- , nlink: 12
- , uid: 1000
- , gid: 1000
- , rdev: 0
- , size: 4096
- , blksize: 4096
- , blocks: 8
- , atime: '2009-06-29T11:11:55Z'
- , mtime: '2009-06-29T11:11:40Z'
- , ctime: '2009-06-29T11:11:40Z'
- }
+ { dev: 2049,
+ ino: 305352,
+ mode: 16877,
+ nlink: 12,
+ uid: 1000,
+ gid: 1000,
+ rdev: 0,
+ size: 4096,
+ blksize: 4096,
+ blocks: 8,
+ atime: '2009-06-29T11:11:55Z',
+ mtime: '2009-06-29T11:11:40Z',
+ ctime: '2009-06-29T11:11:40Z' }
See the `fs.Stats` section below for more information.
`options` is an object with the following defaults:
- { 'flags': 'r'
- , 'encoding': null
- , 'mode': 0666
- , 'bufferSize': 4 * 1024
- }
+ { flags: 'r',
+ encoding: null,
+ mode: 0666,
+ bufferSize: 4096 }
`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
`options` is an object with the following defaults:
- { 'flags': 'w'
- , 'encoding': null
- , 'mode': 0666
- }
+ { flags: 'w',
+ encoding: null,
+ mode: 0666 }
HTTP message headers are represented by an object like this:
- { 'content-length': '123'
- , 'content-type': 'text/plain'
- , 'connection': 'keep-alive'
- , 'accept': '*/*'
- }
+ { 'content-length': '123',
+ 'content-type': 'text/plain',
+ 'connection': 'keep-alive',
+ 'accept': '*/*' }
Keys are lowercased. Values are not modified.
`require('url').parse(request.url)`. Example:
node> require('url').parse('/status?name=ryan')
- { href: '/status?name=ryan'
- , search: '?name=ryan'
- , query: 'name=ryan'
- , pathname: '/status'
- }
+ { href: '/status?name=ryan',
+ search: '?name=ryan',
+ query: 'name=ryan',
+ pathname: '/status' }
If you would like to extract the params from the query string,
you can use the `require('querystring').parse` function, or pass
`true` as the second argument to `require('url').parse`. Example:
node> require('url').parse('/status?name=ryan', true)
- { href: '/status?name=ryan'
- , search: '?name=ryan'
- , query: { name: 'ryan' }
- , pathname: '/status'
- }
+ { href: '/status?name=ryan',
+ search: '?name=ryan',
+ query: { name: 'ryan' },
+ pathname: '/status' }
var body = 'hello world';
response.writeHead(200, {
'Content-Length': body.length,
- 'Content-Type': 'text/plain'
- });
+ 'Content-Type': 'text/plain' });
This method must only be called once on a message and it must
be called before `response.end()` is called.
This will generate:
- { rss: 4935680
- , vsize: 41893888
- , heapTotal: 1826816
- , heapUsed: 650472
- }
+ { rss: 4935680,
+ vsize: 41893888,
+ heapTotal: 1826816,
+ heapUsed: 650472 }
`heapTotal` and `heapUsed` refer to V8's memory usage.
querystring.parse('a=b&b=c')
// returns
- { 'a': 'b'
- , 'b': 'c'
- }
+ { a: 'b', b: 'c' }
### querystring.escape