UNPKG

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.

19 lines (16 loc) 531 B
/** Best way to stringify a value! Default indent: 2 */ export 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) }