freeCodeCamp/client/src/utils/format.js
Oliver Eyton-Williams d40be9cbf2 fix: use util.inspect for more reliable logging (#37880)
The tests are probably overkill, but this way we will know if
util.inspect changes dramatically.
2019-12-06 08:37:10 -08:00

8 lines
203 B
JavaScript

import { inspect } from 'util';
export function format(x) {
// we're trying to mimic console.log, so we avoid wrapping strings in quotes:
if (typeof x === 'string') return x;
return inspect(x);
}