30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
/**
|
|
* Encapsulates JSON.stringify function to detect and handle different types of errors (eg. Circular Structure).
|
|
*
|
|
* @remarks
|
|
* Circular Structure:
|
|
* - It detects when the provided value has circular references and replaces them with [Circular *.{path to the value being referenced}].
|
|
*
|
|
* _replacer internal function:
|
|
* - Have similar functionality as the JSON.stringify internal toJSON function, but with the difference that only affects this stringify functionality.
|
|
*
|
|
* @example
|
|
* // Circular Structure:
|
|
* {
|
|
* "item": {
|
|
* "name": "parent",
|
|
* "parent": null,
|
|
* "child": {
|
|
* "name": "child",
|
|
* "parent": "[Circular *.item]" // => obj.item.child.parent = obj.item
|
|
* }
|
|
* }
|
|
* }
|
|
*
|
|
* @param value — A JavaScript value, usually an object or array, to be converted.
|
|
* @param replacer — A function that transforms the results.
|
|
* @param space — Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
* @returns {string} The converted JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
*/
|
|
export declare function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
|
//# sourceMappingURL=stringify.d.ts.map
|