@pmoo/testy
Version:
A minimal testing framework, for educational purposes.
16 lines (13 loc) • 487 B
JavaScript
import util from 'node:util';
import { notNullOrUndefined } from './types.js';
const prettyPrint = object => {
const excludedToStrings = [Object.prototype.toString, String.prototype.toString, Array.prototype.toString];
const shouldUseToStringMethod = notNullOrUndefined(object) && !excludedToStrings.includes(object.toString);
return shouldUseToStringMethod ? object.toString() : util.inspect(object, {
depth: Infinity,
compact: true,
});
};
export {
prettyPrint,
};