RoadmapShopEvents
Skip to main content

Home > @rushstack/node-core-library > Text

Text class

Operations for working with strings that contain text.

Signature:
export declare class Text

Remarks

The utilities provided by this class are intended to be simple, small, and very broadly applicable.

Methods

MethodModifiersDescription
convertTo(input, newlineKind)staticConverts all newlines in the provided string to use the specified newline type.
convertToCrLf(input)staticConverts all newlines in the provided string to use Windows-style CRLF end of line characters.
convertToLf(input)staticConverts all newlines in the provided string to use POSIX-style LF end of line characters. POSIX is a registered trademark of the Institute of Electrical and Electronic Engineers, Inc.
ensureTrailingNewline(s, newlineKind)staticReturns the input string with a trailing \n character appended, if not already present.
getNewline(newlineKind)staticReturns the newline character sequence for the specified NewlineKind.
padEnd(s, minimumLength, paddingCharacter)staticAppend characters to the end of a string to ensure the result has a minimum length.
padStart(s, minimumLength, paddingCharacter)staticAppend characters to the start of a string to ensure the result has a minimum length.
replaceAll(input, searchValue, replaceValue)staticReturns the same thing as targetString.replace(searchValue, replaceValue), except that all matches are replaced, rather than just the first match.
truncateWithEllipsis(s, maximumLength)staticIf the string is longer than maximumLength characters, truncate it to that length using "..." to indicate the truncation.