OptionaluseWhether to use the toString() method, but only if a custom one exists on objects.
@default: undefined, i.e false
OptionalfunctionWhether to print the function 'body' (using toString()), just the name, or the default inspect message [Function: functionName] as a string.
@default: undefined / hard coded behaviour is 'inspect'
OptionalnestingWhether to use nesting of each item in new line, when printing objects / arrays
@default: undefined, i.e false
OptionalstringifyWhether to use stringify on objects i.e convert them to JSON in a safe way, using 'json-stringify-safe'.
@default: undefined, i.e false
OptionaldepthMax depth level of object/array nesting to consider, all levels higher are ignored.
A string to detail this is added in the place - see inspect!
OptionalmaxMax number of items to consider in Arrays / Sets (at their root level). Remaining items are omitted (use omitted: true to print comment)
OptionalmaxMax number of props to consider in Objects/Maps (at their root level). Props order is as retrieved by JS, there's no sorting. Remaining props are omitted (use omitted: true to print comment)
OptionalomittedOptionalmapPrint Map as an Object, or as a string
true: print an object, that can be copy-pasted eg
`new Map(Object.entries({ aa: 11, bb: 4 }))`
false: print a string, using inspect eg
`Map(2) { 'aa' => 11, 'bb' => 4 }`
OptionalsetPrint Set as an Array, or as a string
true: print an Array that can de dehydrated, eg new Set([1, 2, 3]) /* OMITTED 1 Set items - maxItems = 3... false: print as a string, using inspect eg Set(3) { 1, 2, 3 }` /* OMITTED 1 Set items - maxItems = 3...
OptionalinstancePrint the class of the instance (i.e the constructor), as an artificial key (a.k.a discriminator).
false / undefined (default) - do not add a fake object key to indicate class
true: use "class" as prop key, the class / constructor itself as value, eg { class: Person name: 'Angelos }
string, eg "kind" or "constructor": use this string as the prop key, as above, eg:
With options: { print: { instanceClass: 'kind' } }
We print { kind: Person name: 'Angelos' }
For example with options:
{
print: {
instanceClass: (__, constructor) => __theClass__: '${constructor.name}'
}
}
We print
{ theClass: 'Person' name: 'Angelos' }
OptionalundefinedWhat to replace undefined, when outputing JSON-like via print.stringify
For example 'null' or '[Undefined]'. If it is 'null' then no quotes are added.
@default: '[Undefined]'
OptionalsymbolSelects how to format a Symbol.
For a Symbol('label') we can print:
Symbol.for('label') (or "Symbol.for('label')") in stringify'Symbol(label)' (or "Symbol(label)") in stringifySymbol('label') (or "Symbol('label')") in stringifySymbol(label) (or "Symbol(label)") in stringifyIf 'label' is a number, the inside quotes are omitted.
OptionaldateHow to format Date object values
With new Date(2023, 11, 31, 23, 58, 59, 250)
new Date(2023, 11, 31, 23, 58, 59, 250)Start any of these with '@' (eg '@toISOString') to adjust timezone minutes offset (@see https://stackoverflow.com/questions/43591771/new-date-has-wrong-time-in-node-js/71262913#71262913)
@default: 'new'
OptionalemptyWhat to print instead of null, for empty items in sparse arrays, when stringify: true
It receives no quotes, so use "myEmptyLabel" (with double quotes) for strings, since this is meant for JSON.
If it is false, nothing is printed, which will make your Arrays indexes correspond to the wrong value (but they look better!). Also keep in mind that comments on {stringify: false} are off, so with false no information will convey the Array was sparse!
@default: "[Empty item]"
OptionalargsHow to format arguments pseudo-array (received in function () {})
Eg for value (function(a, b, c) { return arguments })(1, 'foo', {prop: 'val'})
[1, 'foo', {prop: 'val'}] - default{'0': 1, '1': 'foo', '2': { prop: 'val'}}OptionalobjectOptionalcolorsOptionalinherited@default: false
OptionaltransformA callback to transform a value or filter object props / array items.
Its behavior depends on the returned value from transform():
PrintOptions, when printMode="print".
Note: these work only with printMode="print", ignored otherwise
Note: it is a class only for validation purposes via class-validator, but it's not meant to be instantiated.