Package Exports
- purdy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (purdy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Purdy 
Print things real purdy for nodejs.
Usage
var Purdy = require('purdy');
Purdy({list: [1,2,3], string: 'some string'});
Purdy(object, [options])
Prints anything indented, and with arrays with index keys, and different types in colors such that it's very easy to get an overview of what object you're dealing with.
object
- anything, number, object, array, etc.options
- optional object with the following keys.plain
- whentrue
, prints result without colors. Defaults tofalse
with tty,true
when not.path
- whentrue
, prints result with a path (To be used with Hoek.reach())pathPrefix
- prefix for path. default://
arrayIndex
- enables index printing for arrays. default:true
indent
- defines the number of spaces to indent default:4
align
- determines how to align object keys. default:left
depth
- tells purdy how many times to recurse while formatting the object. This is useful for viewing complicated objects. default:2
. Set tonull
to recurse indefinitely
Purdy.stringify(object, [options])
This function returns a string without printing it to stdout. This may prove to be useful for log files other other applications.
var purdyString = Purdy.stringify({a: 'b'}, {plain: true});
writeLog(purdyString);
Examples
var Purdy = require('purdy');
var circularObj = { };
circularObj.a = circularObj;
Purdy({
integer: Date.now(),
string: 'foo',
anonymous: Purdy,
defined: function Yes() {},
nested: {hello: 'hapi'},
error: new Error('bad'),
null: null,
undefined: undefined,
regexp: new RegExp,
falseBool: false,
trueBool: true,
emptyArr: [],
circular: circularObj,
date: new Date(),
arrayWithVisibleIndex: [ 'one', 'two', 'three' ]
});
// var obj = {
// travel: {
// down: {
// a: [{
// path: 'to get here'
// }]
// }
// }
// Purdy(obj, { path: true });
{
travel: {
// travel.down
down: {
// travel.down.a
a: [
// travel.down.a.0
[0] {
// travel.down.a.0.path
path: 'to get here'
}
]
}
}
}
// var Hoek = require('hoek');
// Purdy(Hoek.reach(obj, 'travel.down.a.0.path'));
{
path: 'to get here'
}
Command-line Interface
This package also installs the purdy
CLI tool. Right now this just prints
any JSON file with default options.
purdy package.json
will, for example, print the JSON contents of
package.json.
Similarly, cat package.json | purdy -
will use stdin to print the contents.
Acknowledgements
- Michael Dvorkin for Awesome Print