@brusalk/react-wow-addon
Version:
React-style UI Framework for World of Warcraft AddOns
26 lines (25 loc) • 684 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringify = void 0;
function stringify(obj, depth = 1) {
if (typeof obj === 'string') {
return `"${obj}"`;
}
if (typeof obj === 'function') {
return `<function>`;
}
if (typeof obj === 'boolean' || typeof obj === 'number') {
return `${obj}`;
}
if (typeof obj === 'undefined' || !obj) {
return 'nil';
}
if (depth < 0) {
return '{ ... }';
}
const inner = Object.keys(obj)
.map(key => `${key}: ${stringify(obj[key], depth - 1)}`)
.join(', ');
return `{ ${inner} }`;
}
exports.stringify = stringify;