@specs-feup/lara
Version:
A js port of the popular framework for building source-to-source compilers
80 lines • 2.78 kB
TypeScript
import { JavaClasses } from "./util/JavaTypes.js";
/**
* Utility methods related to Strings.
*/
export default class Strings {
/**
* Taken from here: https://stackoverflow.com/questions/154059/how-do-you-check-for-an-empty-string-in-javascript
*
* @returns true if the given string is blank or contains only white-space
*
* @deprecated Use JS native methods instead. You can check the link above for more information.
*/
static isEmpty(string: string): boolean;
/**
* Equivalent to JS 'replace'.
*
* @param string - the string to process
* @param oldSequence - the sequence we want to replace. To replace all occurrences, use a Regex with the 'g' modifier (e.g., /<regex>/g). Regexes in string format automatically assumes the 'g' modifier.
* @param newSequence - the new value that will be used instead of the old value
*
* @returns the string after the replacement is done
*
* @deprecated Use the JS 'replace' method instead
*/
static replacer(string: string, oldSequence: string | RegExp, newSequence: string): string;
/**
* Escapes HTML code.
*
* @returns String with escaped code
*/
static escapeHtml(html: string): any;
/**
* Escapes JSON content.
*
* @returns String with escaped code
*/
static escapeJson(jsonContents: string): string;
/**
* Iterates over the given string, line-by-line, looking for the given prefix. If found, returns the contents of the line after the prefix.
*
* @returns
*/
static extractValue(prefix: string, contents: string, errorOnUndefined?: boolean): string | undefined;
static asLines(string?: string): JavaClasses.List<string> | undefined;
/**
* @param value - The value to convert to Json.
*
* @returns A string representing the given value in the Json format.
*
* @deprecated Use the JS 'JSON.stringify' method instead
*/
static toJson(value: object): string;
/**
* Returns a random unique identifier.
*/
static uuid(): string;
/**
* Normalizes a given string:
* 1) Replaces \\r\\n with \\n
* 2) Trims lines and removes empty lines
*/
static normalize(string: string): any;
/**
* Converts a given object to a XML string.
*
* @param object - The object to serialize to XML.
*
* @returns The XML representation of the object.
*/
static toXml(object: object): string;
/**
* Converts a given XML string to an object.
*
* @param xmlString - The XML representation of the object.
*
* @returns The deserialized object.
*/
static fromXml(xmlString: string): object;
}
//# sourceMappingURL=Strings.d.ts.map