topkat-utils
Version:
A comprehensive collection of TypeScript/JavaScript utility functions for common programming tasks. Includes validation, object manipulation, date handling, string formatting, and more. Zero dependencies, fully typed, and optimized for performance.
21 lines • 777 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeCircularJSONstringify = void 0;
/** Best way to stringify a value! Default indent: 2 */
function removeCircularJSONstringify(object, indent = 2) {
const getCircularReplacer = () => {
const seen = new WeakSet();
return (_, value) => {
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
return JSON.stringify(object, getCircularReplacer(), indent);
}
exports.removeCircularJSONstringify = removeCircularJSONstringify;
//# sourceMappingURL=remove-circular-json-stringify.js.map