UNPKG

nope-js-browser

Version:

NoPE Runtime for the Browser. For nodejs please use nope-js-node

83 lines (82 loc) 2.85 kB
/** * @author Martin Karkowski * @email m.karkowski@zema.de * @desc [description] */ /** * Helper Function to varify the given string. * Removes every char which doesn't match a variable name. * (a-z, A-Z, 0-9). * * If `str` starts with an invalid char, (like a number), * an underscore is added. * @param {string} str the Stirng * @returns {string} the adapted name */ export declare function varifyString(str: string): string; /** * Replaces all Chars in a String * @param str base string * @param value the value which should be replaced, Or an array containing the value and replacer * @param replacement the value which is used as replacement */ export declare function replaceAll(str: string, value: string | Array<[string, string] | string>, replacement?: string): string; /** * Function to Pad a String. * @param num The Number to pad * @param size the amount of zeros to add * @param maxLength The max length of the number. */ export declare function padString(num: number, size: number, maxLength?: boolean): string; /** * Inserts a String in the String * @param str base string * @param index index where the content should be inserted * @param content the content to insert */ export declare function insert(str: string, index: number, content: string): string; /** * Helper to capitalize the First letter of a string; * @param str The string; * @returns */ export declare function capitalizeFirstLetter(str: string): string; /** * Function to Camelize a String * @param str The String, * @param char A, used to determine "new words" */ export declare function camelize(str: string, char?: string): string; /** * Function to convert a text to underscore writing (snake-case) * @param str The String to convert. * @param leadingToSmall If set to true, the function ensures, that the name is converted without a leading underscore. * @returns */ export declare function underscore(str: string, leadingToSmall?: boolean): string; /** * Helper to limit the string to a specific length. the rest is reduced by the limitChars * * @author M.Karkowski * @export * @param {string} str The string to work with * @param {number} length The max length including the limitChars * @param {string} [limitChars="..."] The chars which should be used to express limiting * @return {*} {{ * isLimited: boolean, * original: string, * limited: string, * }} */ export declare function limitString(str: string, length: number, limitChars?: string): { isLimited: boolean; original: string; limited: string; }; /** * Helper to insert new lines after a given amount of time. * @param str * @param maxLength * @returns */ export declare function insertNewLines(str: string, maxLength?: number): string[];