UNPKG

ucl-parser

Version:

A Universal Configuration Language (UCL) parser and configuration library.

57 lines (52 loc) 1.59 kB
type UCLValue = string | number | boolean | null | UCLArray | UCLObject; type UCLArray = UCLValue[]; interface UCLObject { [key: string]: UCLValue; } declare class UCLParser { private config; private currentSection; private defaults; private envVars; private basePath; constructor(); parseFile(filepath: string): UCLObject; parseString(content: string): UCLObject; private _processIncludes; private _parseLines; private _parseDefaultsSection; private _parseKeyValue; private _splitKeyValue; private _parseMultilineValue; private _parseValue; private _evaluateExpression; private _evaluateSimpleExpression; private _resolveOperand; private _resolveReference; private _setNestedValue; private _getNestedValue; private _applyDefaults; private _setNestedValueByPath; } declare class UCLError extends Error { constructor(message: string); } declare class UCLSyntaxError extends UCLError { constructor(message: string); } declare class UCLReferenceError extends UCLError { constructor(message: string); } declare class UCLTypeError extends UCLError { constructor(message: string); } /** * Convenience function to parse a UCL file. */ declare function parseUclFile(filepath: string): UCLObject; /** * Convenience function to parse UCL content from a string. */ declare function parseUclString(content: string): UCLObject; export { UCLError, UCLParser, UCLReferenceError, UCLSyntaxError, UCLTypeError, parseUclFile, parseUclString }; export type { UCLArray, UCLObject, UCLValue };