UNPKG

yini-parser

Version:

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

44 lines (43 loc) 2.59 kB
import { TJSObject } from './core/types'; /** * This class is the public API, which exposes only parse(..) and * parseFile(..), rest of the implementation details are hidden. * @note Only parse and parseFile are public. */ export default class YINI { static filePath: string; /** * Parse YINI content into a JavaScript object. * * @param yiniContent YINI code as a string (multi‑line content supported). * @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas). * @param bailSensitivity Controls how errors and warnings are handled: * - `'auto'` : Auto‑select level (strict→1, lenient→0) * - `0` / `'Ignore-Errors'` : Continue parsing despite errors; log them and attempt recovery. * - `1` / `'Abort-on-Errors'` : Stop parsing on the first error. * - `2` / `'Abort-Even-on-Warnings'`: Stop parsing on the first warning **or** error. * @param includeMetaData If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object. * * @note The order of properties in each output object may differ from their order in the YINI source. * * @returns A JavaScript object representing the parsed YINI content. */ static parse: (yiniContent: string, strictMode?: boolean, bailSensitivity?: "auto" | 0 | 1 | 2, includeMetaData?: boolean) => TJSObject; /** * Parse a YINI file into a JavaScript object. * * @param yiniFile Path to the YINI file. * @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas). * @param bailSensitivity Controls how errors and warnings are handled: * - `'auto'` : Auto‑select level (strict→1, lenient→0) * - `0` / `'Ignore-Errors'` : Continue parsing despite errors; log them and attempt recovery. * - `1` / `'Abort-on-Errors'` : Stop parsing on the first error. * - `2` / `'Abort-Even-on-Warnings'`: Stop parsing on the first warning **or** error. * @param includeMetaData If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object. * * @note The order of properties in each output object may differ from their order in the YINI source. * * @returns A JavaScript object representing the parsed YINI content. */ static parseFile: (filePath: string, strictMode?: boolean, bailSensitivity?: "auto" | 0 | 1 | 2, includeMetaData?: boolean) => TJSObject; }