ocat v0.3.0
ocat 
Inspect an object various ways in order to easily generate test cases.
Installation
npm install ocatAPI
ocat.inspect
Inspects object and returns result.
Parameters
ocat.bag
Inspects object and adds results to a bag.
This entire bag is logged at process.on('exit').
Parameters
ocat.file
Same as @see ocat.log, but writes to ocat.tmpFile * at /tmp/ocat.txt
on Unixes and who knows on Windows (os.tmpdir()/ocat.txt).
This is useful if you want to read isolated ocat output into your editor without other output, i.e. by your test runner.
Vim Example:
:r !OCAT_COLOR=0 OCAT_DEPTH=0 OCAT_RM=1 node % 2>&1 > /dev/null && cat /tmp/ocat.txtwill read the ocat printed output right into your editor. You should probably bind that to a shortcut. ;)
Tail Example:
In another terminal pane do:
tail -f /tmp/ocat.txtto see logged objects every time you run your tests/code.
Parameters
ocat.log
Inspects object and logs it to stderr immediately.
The given opts override all other options for each supplied property, which are derived as follows:
- ocat.opts, the default opts:
prefix: '', suffix: '', indent: '', color: true, depth: 1, commaFirst: true OCAT_COLORandOCAT_COMMAFIRSTto override the related defaults, i.e.OCAT_COLOR=0 node my.jsincludes no colors- opts passed to
ocat.createfor thatocatinstance only - opts passed to
ocat.logandocat.bag
Parameters
objObject object to inspectoptsObject options inherit from opts passed tocreateand thenocat.opts.opts.prefixString? the prefix to insert before the logged objectopts.suffixString? the suffix to insert after the logged objectopts.indentString? the indentation to apply to each lineopts.colorBoolean? iftruelogging in colorsopts.depthNumber? depth to which the object is inspectedopts.commaFirstBoolean? iftruecommaFirst style is used when logging without color** (default:true)
ocat.applyRes5Opts
Applies preconfigured opts with prefix + indentation and depth that work well in lots of scenarios.
Example
const ocat = require('ocat').applyRes5Opts()Returns Object ocat
ocat.opts
Start out as default options @see ocat.log. Allow overriding ocat options for all instances.
ocat.resetOpts
Resets ocat.opts to default opts.
ocat.create
Creates an ocat instance with the supplied options.
Parameters
optsObject options (same as @see ocat.log)
Returns Object ocat instance
ocat.tmpFile
The file into which ocat.file writes. Set it to any other path you like to use instead.
ocat.rm
Removes the ocat.tmpFile
If the an env var OCAT_RM=1 is present, the file is removed on startup.
License
MIT
