mirror of
https://github.com/Warky-Devs/artemis-kit.git
synced 2025-05-18 19:37:28 +00:00
Added stringify_json
This commit is contained in:
parent
4058dd37f8
commit
c04000c5cf
@ -14,7 +14,7 @@ export interface RefObject {
|
|||||||
* @param replacer - Optional function to replace values during the process
|
* @param replacer - Optional function to replace values during the process
|
||||||
* @returns A decycled copy of the object
|
* @returns A decycled copy of the object
|
||||||
*/
|
*/
|
||||||
export function decycle<T>(
|
export function decycle<T=any>(
|
||||||
object: T,
|
object: T,
|
||||||
replacer?: (value: any) => any
|
replacer?: (value: any) => any
|
||||||
): any {
|
): any {
|
||||||
@ -130,4 +130,17 @@ export function retrocycle<T>($: T): T {
|
|||||||
}
|
}
|
||||||
}($));
|
}($));
|
||||||
return $;
|
return $;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @description Converts a object with circular references to JSON
|
||||||
|
* @param json
|
||||||
|
* @param object
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function stringify_json<T=any>(
|
||||||
|
object: T,
|
||||||
|
) {
|
||||||
|
return JSON.stringify(retrocycle(object))
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
export {getNestedValue,setNestedValue} from './nested'
|
export {getNestedValue,setNestedValue} from './nested'
|
||||||
export {objectCompare} from './compare'
|
export {objectCompare} from './compare'
|
||||||
export {createSelectOptions} from './util'
|
export {createSelectOptions} from './util'
|
||||||
export {decycle,retrocycle} from './decycle'
|
export {decycle,retrocycle, stringify_json} from './decycle'
|
||||||
export type {RefObject} from './decycle'
|
export type {RefObject} from './decycle'
|
Loading…
Reference in New Issue
Block a user