arginfo
Install
$ npm install arginfo
Usage
Calling arginfo(arg)
returns a string representation of arg
using node.js' util.inspect
. It prefixes the value with the type of the argument (whether it is a primitive type or a built-in object) such that the formatting is consistent across all built-in types:
; // [number: 2]; // [object: {}]; // [string: '?']; // [boolean: true]; // [RegExp: /org/]; // [Set: {}]; // [String: '']; // [Error: wtf]
Example
var arginfo = ; { if'string' !== typeof str console; }
Settings
By default, arginfo will call util.inspect
with a depth
of null
. To limit the inspection depth of printing object properties, use arginfo.depth
. eg:
var arginfo = ;arginfo;; // [object: { a: { b: [Object] } }]
Types
Primitive types:
- boolean
- number
- string
- object
- function
- symbol
Built-in objects:
- Boolean
- Number
- String
- Array
- Error
- RegExp
- Date
- Map
- Set
- WeakMap
- WeakSet
- Promise
- Generator
- DataView
- ArrayBuffer