UNPKG

yini-parser

Version:

Readable configuration without YAML foot-guns or JSON noise. The official Node.js parser for YINI config format — An INI-inspired configuration format with clear nesting, explicit types, and predictable parsing.

48 lines (46 loc) 2.11 kB
/** * This file contains specific YINI helper functions (utils). * @note More general helper functions should go into the dir "src/utils/". */ import { TScalarValue, TValueLiteral } from '../core/internalTypes'; /** * 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; export declare const printLiteral: (value: TValueLiteral) => void; export declare const isScalar: (v: TValueLiteral) => v is TScalarValue;