What does the util module in node.js do?

I'm aware of how to include the util module,

var util = require('util');

However what does it mean and what does it do?

Edit Yes, I know about the docs http://nodejs.org/api/util.html However what I want is something of an explanation of when and why I would use the util module..


The node.js "util" module provides "utility" functions that are potentially helpful to a developer but don't really belong anywhere else. (It is, in fact, a general programming convention to have a module or namespace named "util" for general purpose utility functions.) You would use the functions in the "util" module if you had a need to use any of them.

For example, if you need to test if an arbitrary value is an array you could write your own function or you could use util.isArray(...):

function myIsArray(o) {
  return (typeof(o)==='object') && (o.constructor === Array);
}

// Or...
var util = require('util');
if (util.isArray(someValue)) {
  // ...
}

In general, after reading the documentation for any of the utility functions you can make an assessment about whether or not you could, or would, like to use them in your own program. If you decide that doing so is a good idea then you can do it.