diff options
author | Micheil Smith <micheil@brandedcode.com> | 2010-10-28 23:18:16 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-10-28 14:59:15 -0700 |
commit | e190c9616ed0b05eb66e1ae6681a8bb4a5f5f3e5 (patch) | |
tree | 4ae307ad3dc34b3176bae6a24968a7e1c93b3dc9 /doc/api/util.markdown | |
parent | 1eb547fec126ecbf9197d0bc949459d66509bcd1 (diff) | |
download | node-e190c9616ed0b05eb66e1ae6681a8bb4a5f5f3e5.tar.gz |
Splitting documentation
Diffstat (limited to 'doc/api/util.markdown')
-rw-r--r-- | doc/api/util.markdown | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/doc/api/util.markdown b/doc/api/util.markdown new file mode 100644 index 000000000..cddf47d86 --- /dev/null +++ b/doc/api/util.markdown @@ -0,0 +1,57 @@ +## util + +These functions are in the module `'util'`. Use `require('util')` to access +them. + + +### util.print(string) + +Like `console.log()` but without the trailing newline. + + require('util').print('String with no newline'); + + +### util.debug(string) + +A synchronous output function. Will block the process and +output `string` immediately to `stderr`. + + require('util').debug('message on stderr'); + + +### util.log(string) + +Output with timestamp on `stdout`. + + require('util').log('Timestmaped message.'); + + +### util.inspect(object, showHidden=false, depth=2) + +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. + +If `depth` is provided, it tells `inspect` how many times to recurse while +formatting the object. This is useful for inspecting large complicated objects. + +The default is to only recurse twice. To make it recurse indefinitely, pass +in `null` for `depth`. + +Example of inspecting all properties of the `util` object: + + var util = require('util'); + + console.log(util.inspect(util, true, null)); + + +### util.pump(readableStream, writeableStream, [callback]) + +Experimental + +Read the data from `readableStream` and send it to the `writableStream`. +When `writeableStream.write(data)` returns `false` `readableStream` will be +paused until the `drain` event occurs on the `writableStream`. `callback` gets +an error as its only argument and is called when `writableStream` is closed or +when an error occurs. |