The object to be converted to a diagnostic string value
Optionalformat: number | boolean
Identifies whether the JSON value should be formated
true - Format with 4 spacesfalse (or not Truthy) - Do not formatOptionalmaxLength: number
(Since 0.20.0) The maximum length of the returned string, when it is longer it is truncated and
ends with "...", which is included in the length (like strTruncate), and a surrogate pair (eg. an emoji) is
not split (so the result can be one shorter). It must be at least 3 (the length of the "..."), a smaller positive value is rounded up to 3 so the
result is "...", and a fraction is rounded down. When it is zero, negative or not a number the length is not
limited. So dumpObj should not be passed directly as a callback, eg. arr.map(dumpObj) passes the index as the
format and the array as the maxLength (which TypeScript rejects, as it isn't a number), use a function instead,
eg. arr.map((value) => dumpObj(value)).
A string representation of the object suitable for diagnostics logging
let obj = { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } };
let objStr = dumpObj(obj);
// objStr === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let objStrFmt = dumpObj(obj, true);
// objStrFmt === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
let objStrFmt2 = dumpObj(obj, 2);
// objStrFmt2 === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
let objStrFmt3 = dumpObj(obj, 0);
// objStrFmt3 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let objStrFmt4 = dumpObj(obj, false);
// objStrFmt4 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let objStrFmt5 = dumpObj(obj, null);
// objStrFmt5 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let objStrFmt6 = dumpObj(obj, undefined);
// objStrFmt6 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let objStrFmt7 = dumpObj(obj, "");
// objStrFmt7 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
let err = new Error("Hello Darkness");
let errStr = dumpObj(err);
// errStr === "[object Error]: { stack: 'Error: Hello Darkness\n at <anonymous>:1:13', message: 'Hello Darkness', name: 'Error'"
let errStrFmt = dumpObj(err, true);
// errStrFmt === "[object Error]: {\n stack: "Error: Hello Darkness\n at <anonymous>:1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
let errStrFmt2 = dumpObj(err, 2);
// errStrFmt2 === "[object Error]: {\n stack: "Error: Hello Darkness\n at <anonymous>:1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
let errStrFmt3 = dumpObj(err, 0);
// errStrFmt3 === "[object Error]: { stack: "Error: Hello Darkness\n at <anonymous>:1:13", message: "Hello Darkness", name: "Error" }"
let objStrMax = dumpObj(obj, false, 20);
// objStrMax === "[object Object]: ..."
let objStrFmtMax = dumpObj(obj, true, 30);
// objStrFmtMax === "[object Object]: {\n a: 1..."
Returns string representation of an object suitable for diagnostics logging.