basant307/AI_Governance_Project
048
1// Original from DefinitelyTyped. Thanks a million2// Type definitions for comment-json 1.13// Project: https://github.com/kaelzhang/node-comment-json4// Definitions by: Jason Dent <https://github.com/Jason3S>5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped6 7declare const commentSymbol: unique symbol8 9export type CommentPrefix = 'before'10 | 'after-prop'11 | 'after-colon'12 | 'after-value'13 | 'after'14 15export type CommentDescriptor = `${CommentPrefix}:${string}`16 | 'before'17 | 'before-all'18 | 'after-all'19 20export type CommentSymbol = typeof commentSymbol21 22export class CommentArray<TValue> extends Array<TValue> {23 [commentSymbol]: CommentToken[]24}25 26export type CommentJSONValue = number27 | string28 | null29 | boolean30 | CommentArray<CommentJSONValue>31 | CommentObject32 33export interface CommentObject {34 [key: string]: CommentJSONValue35 [commentSymbol]: CommentToken[]36}37 38export interface CommentToken {39 type: 'BlockComment' | 'LineComment'40 // The content of the comment, including whitespaces and line breaks41 value: string42 // If the start location is the same line as the previous token,43 // then `inline` is `true`44 inline: boolean45 // But pay attention that,46 // locations will NOT be maintained when stringified47 loc: CommentLocation48}49 50export interface CommentLocation {51 // The start location begins at the `//` or `/*` symbol52 start: Location53 // The end location of multi-line comment ends at the `*/` symbol54 end: Location55}56 57export interface Location {58 line: number59 column: number60}61 62export type Reviver = (k: number | string, v: unknown) => unknown63 64/**65 * Converts a JavaScript Object Notation (JSON) string into an object.66 * @param json A valid JSON string.67 * @param reviver A function that transforms the results. This function is called for each member of the object.68 * @param removesComments If true, the comments won't be maintained, which is often used when we want to get a clean object.69 * If a member contains nested objects, the nested objects are transformed before the parent object is.70 */71export function parse(72 json: string,73 reviver?: Reviver | null,74 removesComments?: boolean75): CommentJSONValue76 77/**78 * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.79 * @param value A JavaScript value, usually an object or array, to be converted.80 * @param replacer A function that transforms the results or an array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.81 * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.82 */83export function stringify(84 value: unknown,85 replacer?: (86 (key: string, value: unknown) => unknown87 ) | Array<number | string> | null,88 space?: string | number89): string90 91 92export function tokenize(input: string, config?: TokenizeOptions): Token[]93 94export interface Token {95 type: string96 value: string97}98 99export interface TokenizeOptions {100 tolerant?: boolean101 range?: boolean102 loc?: boolean103 comment?: boolean104}105 106export function assign<TTarget, TSource>(107 target: TTarget,108 source: TSource,109 // Although it actually accepts more key types and filters then`,110 // we set the type of `keys` stricter111 keys?: readonly (number | string)[]112): TTarget113 