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.
70 lines (69 loc) • 2.57 kB
TypeScript
/**
* This file contains general string helper functions (utils).
* @note More specific YINI helper functions should go into yiniHelpers.ts-file.
*/
export declare const toColRow: (size: number, label: string, value: string) => string;
/**
* Capitalizes the first character of a string.
*
* @param str The input string.
* @returns A new string with the first character uppercased.
*/
export declare const capitalizeFirst: (str: string) => string;
export declare const computeSha256: (content: string) => string;
/**
* Splits a string into an array of lines, handling both LF and CRLF newlines.
* @param content The input string.
* @returns Array of lines (strings).
*/
export declare const splitLines: (content: string) => string[];
/**
* Trims trailing non-letter characters (A–Z, a–z) from the end of a string.
*
* @param str Input string
* @returns String with trailing non-letters removed
*/
export declare const trimTrailingNonLetters: (str: string) => string;
/**
* If a string starts and ends with a backtick `, if so trims the
* first and last character (the backticks).
*/
export declare const trimBackticks: (str: string) => string;
/**
* Returns true if the provided string is enclosed in backticks, e.g. `name`.
*/
export declare const isEnclosedInBackticks: (str: string) => boolean;
/**
* Check if the character is A-Z or a-z.
* @note The string must be of length 1.
* @param character A character in a string.
*/
export declare const isAlpha: (character: string) => boolean;
/**
* Check if the character is a digit (number): 0-9.
* @note The string must be of length 1.
* @param character A character in a string.
*/
export declare const isDigit: (character: string) => boolean;
/**
* @returns Returns the beginning up to (but not including) any first
* encountered newline.
* @note If no newline is found, returns the whole string.
* @example
* `SectionName1
* //value = 11`
* => 'SectionName1'
* @deprecated This seems not useful anymore, use stripCommentsAndAfter(..) instead.
*/
export declare const stripNLAndAfter: (line: string) => string;
/**
* Transforms strings such as 'Id-Name' to 'id_name'.
* Replaces all '-' to '_', and returns rusult in lower case.
*/
export declare const toLowerSnakeCase: (txt: string) => string;
/**
* Transforms strings such as 'Id-Name' to 'id-name'.
* Replaces all '_' to '-', and returns rusult in lower case.
*/
export declare const toLowerKebabCase: (txt: string) => string;
export declare const removeSuffix: (str: string, suffix: string) => string;