UNPKG

yini-parser

Version:

Node.js parser for YINI — a clean, structured INI alternative with types, simple section nesting, comments, and strict mode.

45 lines (43 loc) 1.9 kB
/** * This file contains specific YINI helper functions (utils). * @note More general helper functions should go into the dir "src/utils/". */ /** * Check if the character is a section marker character. * @param character A character in a string. * @note The string must be of length 1. * @throws Will throw if not exactly of length 1. */ export declare const isMarkerCharacter: (character: string) => boolean; /** * @returns Returns the beginning up to (but not including) any comments * starting with //, #, ; or --. * @throws Will throw if consisting more than 1 lines. */ export declare const stripCommentsAndAfter: (line: string) => string; /** * Checks if a string conforms to the identifier rules for section headers and * member key names as defined by the YINI specification, following * the ANTLR4 lexer rule: * IDENT: ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_')* * @throws Will only throw if blank string. * * @satisfies Should satisfy YINI spec 7, chapter: 3.4. Identifiers, Form 1: * Identifier of Simple Form. * @link https://github.com/YINI-lang/YINI-spec/blob/develop/YINI-Specification.md#34-identifiers */ export declare const isValidSimpleIdent: (str: string) => boolean; /** * Checks if a string is a valid backticked phrase/identifier: * - Wrapped in backticks. * - No raw tabs, newlines, or control characters (U+0000–U+001F), except as * escaped sequences (e.g., \n). * - May contain ordinary spaces. * @note Empty is allowed: ``, as in spec (due to conform with the JSON empty key ""). * @throws Will only throw if missing enclosed backtick(s). * * @satisfies Should satisfy YINI spec 7, chapter: 3.4. Identifiers, Form 2: * Backticked Identifier. * @link https://github.com/YINI-lang/YINI-spec/blob/develop/YINI-Specification.md#34-identifiers */ export declare const isValidBacktickedIdent: (str: string) => boolean;