|
| 1 | +declare type StringifyOptions = Partial<{ |
| 2 | + /** |
| 3 | + * A function that alters the behavior of the stringification process, or an |
| 4 | + * array of String and Number objects that serve as a whitelist for |
| 5 | + * selecting/filtering the properties of the value object to be included in |
| 6 | + * the JSON5 string. If this value is null or not provided, all properties |
| 7 | + * of the object are included in the resulting JSON5 string. |
| 8 | + */ |
| 9 | + replacer: ((this: any, key: string, value: any) => any) | (string | number)[]; |
| 10 | + |
| 11 | + /** |
| 12 | + * A String or Number object that's used to insert white space into the |
| 13 | + * output JSON5 string for readability purposes. If this is a Number, it |
| 14 | + * indicates the number of space characters to use as white space; this |
| 15 | + * number is capped at 10 (if it is greater, the value is just 10). Values |
| 16 | + * less than 1 indicate that no space should be used. If this is a String, |
| 17 | + * the string (or the first 10 characters of the string, if it's longer than |
| 18 | + * that) is used as white space. If this parameter is not provided (or is |
| 19 | + * null), no white space is used. If white space is used, trailing commas |
| 20 | + * will be used in objects and arrays. |
| 21 | + */ |
| 22 | + space: string | number; |
| 23 | + |
| 24 | + /** |
| 25 | + * A String representing the quote character to use when serializing strings. |
| 26 | + */ |
| 27 | + quote: string; |
| 28 | +}> |
| 29 | + |
| 30 | +/** |
| 31 | + * Parses a JSON5 string, constructing the JavaScript value or object described |
| 32 | + * by the string. An optional reviver function can be provided to perform a |
| 33 | + * transformation on the resulting object before it is returned. |
| 34 | + * @param text The string to parse as JSON5. |
| 35 | + * @param reviver If a function, this prescribes how the value originally |
| 36 | + * produced by parsing is transformed, before being returned. |
| 37 | + */ |
| 38 | +export function parse(text: string, reviver?: (this: any, key: string, value: any) => any): any; |
| 39 | + |
| 40 | +/** |
| 41 | + * Converts a JavaScript value to a JSON5 string, optionally replacing values |
| 42 | + * if a replacer function is specified, or optionally including only the |
| 43 | + * specified properties if a replacer array is specified. |
| 44 | + * @param value The value to convert to a JSON5 string. |
| 45 | + * @param replacer A function that alters the behavior of the stringification |
| 46 | + * process, or an array of String and Number objects that serve as a whitelist |
| 47 | + * for selecting/filtering the properties of the value object to be included in |
| 48 | + * the JSON5 string. If this value is null or not provided, all properties of |
| 49 | + * the object are included in the resulting JSON5 string. |
| 50 | + * @param space A String or Number object that's used to insert white space |
| 51 | + * into the output JSON5 string for readability purposes. If this is a Number, |
| 52 | + * it indicates the number of space characters to use as white space; this |
| 53 | + * number is capped at 10 (if it is greater, the value is just 10). Values less |
| 54 | + * than 1 indicate that no space should be used. If this is a String, the |
| 55 | + * string (or the first 10 characters of the string, if it's longer than that) |
| 56 | + * is used as white space. If this parameter is not provided (or is null), no |
| 57 | + * white space is used. If white space is used, trailing commas will be used in |
| 58 | + * objects and arrays. |
| 59 | + */ |
| 60 | +export function stringify(value: any, replacer?: ((this: any, key: string, value: any) => any) | (string | number)[], space?: string | number): string; |
| 61 | + |
| 62 | +/** |
| 63 | + * Converts a JavaScript value to a JSON5 string, optionally replacing values |
| 64 | + * if a replacer function is specified, or optionally including only the |
| 65 | + * specified properties if a replacer array is specified. |
| 66 | + * @param value The value to convert to a JSON5 string. |
| 67 | + * @param options An object with the following properties: |
| 68 | + * |
| 69 | + * `replacer`: Same as the `replacer` parameter. |
| 70 | + * |
| 71 | + * `space`: Same as the `space` parameter. |
| 72 | + * |
| 73 | + * `quote`: A String representing the quote character to use when serializing |
| 74 | + * strings. |
| 75 | + */ |
| 76 | +export function stringify(value: any, options?: StringifyOptions): string; |
0 commit comments