Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • StringsHelper

Index

Accessors

Static UNUSUAL_LINE_TERMINATORS

  • get UNUSUAL_LINE_TERMINATORS(): RegExp
  • Returns RegExp

Static UTF8_BOM_CHARACTER

  • get UTF8_BOM_CHARACTER(): string
  • Returns string

Methods

Static breakBetweenGraphemeBreakType

Static commonPrefixLength

  • commonPrefixLength(a: string, b: string): number
  • Parameters

    • a: string
    • b: string

    Returns number

    the length of the common prefix of the two strings.

Static commonSuffixLength

  • commonSuffixLength(a: string, b: string): number
  • Parameters

    • a: string
    • b: string

    Returns number

    the length of the common suffix of the two strings.

Static compare

  • compare(a: string, b: string): number
  • Parameters

    • a: string
    • b: string

    Returns number

Static compareIgnoreCase

  • compareIgnoreCase(a: string, b: string): number
  • Parameters

    • a: string
    • b: string

    Returns number

Static compareSubstring

  • compareSubstring(a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number): number
  • Parameters

    • a: string
    • b: string
    • Default value aStart: number = 0
    • Default value aEnd: number = a.length
    • Default value bStart: number = 0
    • Default value bEnd: number = b.length

    Returns number

Static compareSubstringIgnoreCase

  • compareSubstringIgnoreCase(a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number): number
  • Parameters

    • a: string
    • b: string
    • Default value aStart: number = 0
    • Default value aEnd: number = a.length
    • Default value bStart: number = 0
    • Default value bEnd: number = b.length

    Returns number

Static computeCodePoint

  • computeCodePoint(highSurrogate: number, lowSurrogate: number): number

Static containsEmoji

  • containsEmoji(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Static containsFullWidthCharacter

  • containsFullWidthCharacter(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Static containsRTL

  • containsRTL(str: string): boolean
  • Returns true if str contains any Unicode character that is classified as "R" or "AL".

    Parameters

    • str: string

    Returns boolean

Static containsUnusualLineTerminators

  • containsUnusualLineTerminators(str: string): boolean
  • Returns true if str contains unusual line terminators, like LS or PS

    Parameters

    • str: string

    Returns boolean

Static containsUppercaseCharacter

  • containsUppercaseCharacter(target: string, ignoreEscapedChars?: boolean): boolean
  • Parameters

    • target: string
    • Default value ignoreEscapedChars: boolean = false

    Returns boolean

Static convertSimple2RegExpPattern

  • convertSimple2RegExpPattern(pattern: string): string
  • Parameters

    • pattern: string

    Returns string

Static count

  • count(value: string, character: string): number
  • Counts how often character occurs inside value.

    Parameters

    • value: string
    • character: string

    Returns number

Static createRegExp

  • createRegExp(searchString: string, isRegex: boolean, options?: RegExpOptions): RegExp
  • Parameters

    • searchString: string
    • isRegex: boolean
    • Default value options: RegExpOptions = {}

    Returns RegExp

Static decodeUTF8

  • decodeUTF8(buffer: Uint8Array): string
  • A manual decoding of a UTF8 string. Use only in environments which do not offer native conversion methods!

    Parameters

    • buffer: Uint8Array

    Returns string

Static encodeUTF8

  • encodeUTF8(str: string): Uint8Array
  • A manual encoding of str to UTF8. Use only in environments which do not offer native conversion methods!

    Parameters

    • str: string

    Returns Uint8Array

Static equalsIgnoreCase

  • equalsIgnoreCase(a: string, b: string): boolean
  • Parameters

    • a: string
    • b: string

    Returns boolean

Static escape

  • escape(html: string): string
  • Converts HTML characters inside the string to use entities instead. Makes the string safe from being used e.g. in HTMLElement.innerHTML.

    Parameters

    • html: string

    Returns string

Static escapeRegExpCharacters

  • escapeRegExpCharacters(value: string): string
  • Escapes regular expression characters in a given string

    Parameters

    • value: string

    Returns string

Static firstNonWhitespaceIndex

  • firstNonWhitespaceIndex(str: string): number
  • Returns first index of the string that is not whitespace. If string is empty or contains only whitespaces, returns -1

    Parameters

    • str: string

    Returns number

Static format

  • format(value: string, ...args: any[]): string
  • Helper to produce a string with a variable number of arguments. Insert variable segments into the string using the {n} notation where N is the index of the argument following the string.

    Parameters

    • value: string

      string to which formatting is applied

    • Rest ...args: any[]

      replacements for {n}-entries

    Returns string

Static fuzzyContains

  • fuzzyContains(target: string, query: string): boolean
  • Checks if the characters of the provided query string are included in the target string. The characters do not have to be contiguous within the string.

    Parameters

    • target: string
    • query: string

    Returns boolean

Static getCharContainingOffset

  • getCharContainingOffset(str: string, offset: number): [number, number]
  • Parameters

    • str: string
    • offset: number

    Returns [number, number]

Static getGraphemeBreakType

Static getLeadingWhitespace

  • getLeadingWhitespace(str: string, start?: number, end?: number): string
  • Returns the leading whitespace of the string. If the string contains only whitespaces, returns entire string

    Parameters

    • str: string
    • Default value start: number = 0
    • Default value end: number = str.length

    Returns string

Static getNLines

  • getNLines(str: string, n?: number): string
  • Parameters

    • str: string
    • Default value n: number = 1

    Returns string

Static getNextCodePoint

  • getNextCodePoint(str: string, len: number, offset: number): number
  • get the code point that begins at offset offset

    Parameters

    • str: string
    • len: number
    • offset: number

    Returns number

Static isBasicASCII

  • isBasicASCII(str: string): boolean
  • Returns true if str contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \n, \r, \t

    Parameters

    • str: string

    Returns boolean

Static isEmojiImprecise

  • isEmojiImprecise(x: number): boolean

Static isFalsyOrWhitespace

  • isFalsyOrWhitespace(str: string | undefined): boolean
  • Parameters

    • str: string | undefined

    Returns boolean

Static isFullWidthCharacter

  • isFullWidthCharacter(charCode: number): boolean
  • Parameters

    • charCode: number

    Returns boolean

Static isHighSurrogate

  • isHighSurrogate(charCode: number): boolean

Static isLowSurrogate

  • isLowSurrogate(charCode: number): boolean

Static isLowerAsciiLetter

  • isLowerAsciiLetter(code: number): boolean
  • Parameters

    • code: number

    Returns boolean

Static isUpperAsciiLetter

  • isUpperAsciiLetter(code: number): boolean
  • Parameters

    • code: number

    Returns boolean

Static lastNonWhitespaceIndex

  • lastNonWhitespaceIndex(str: string, startIndex?: number): number
  • Returns last index of the string that is not whitespace. If string is empty or contains only whitespaces, returns -1

    Parameters

    • str: string
    • Default value startIndex: number = str.length - 1

    Returns number

Static lcut

  • lcut(text: string, n: number): string
  • Given a string and a max length returns a shorted version. Shorting happens at favorable positions - such as whitespace or punctuation characters.

    Parameters

    • text: string
    • n: number

    Returns string

Static ltrim

  • ltrim(haystack: string, needle: string): string
  • Removes all occurrences of needle from the beginning of haystack.

    Parameters

    • haystack: string

      string to trim

    • needle: string

      the thing to trim

    Returns string

Static nextCharLength

  • nextCharLength(str: string, offset: number): number
  • Parameters

    • str: string
    • offset: number

    Returns number

Static prevCharLength

  • prevCharLength(str: string, offset: number): number
  • Parameters

    • str: string
    • offset: number

    Returns number

Static regExpContainsBackreference

  • regExpContainsBackreference(regexpValue: string): boolean
  • Parameters

    • regexpValue: string

    Returns boolean

Static regExpFlags

  • regExpFlags(regexp: RegExp): string
  • Parameters

    • regexp: RegExp

    Returns string

Static regExpLeadsToEndlessLoop

  • regExpLeadsToEndlessLoop(regexp: RegExp): boolean
  • Parameters

    • regexp: RegExp

    Returns boolean

Static removeAnsiEscapeCodes

  • removeAnsiEscapeCodes(str: string): string
  • Parameters

    • str: string

    Returns string

Static rtrim

  • rtrim(haystack: string, needle: string): string
  • Removes all occurrences of needle from the end of haystack.

    Parameters

    • haystack: string

      string to trim

    • needle: string

      the thing to trim

    Returns string

Static singleLetterHash

  • singleLetterHash(n: number): string
  • Produces 'a'-'z', followed by 'A'-'Z'... followed by 'a'-'z', etc.

    Parameters

    • n: number

    Returns string

Static splitLines

  • splitLines(str: string): string[]
  • Parameters

    • str: string

    Returns string[]

Static startsWithIgnoreCase

  • startsWithIgnoreCase(str: string, candidate: string): boolean
  • Parameters

    • str: string
    • candidate: string

    Returns boolean

Static startsWithUTF8BOM

  • startsWithUTF8BOM(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

Static stripUTF8BOM

  • stripUTF8BOM(str: string): string
  • Parameters

    • str: string

    Returns string

Static stripWildcards

  • stripWildcards(pattern: string): string
  • Parameters

    • pattern: string

    Returns string

Static trim

  • trim(haystack: string, needle?: string): string
  • Removes all occurrences of needle from the beginning and end of haystack.

    Parameters

    • haystack: string

      string to trim

    • Default value needle: string = " "

      the thing to trim (default is a blank)

    Returns string

Static truncate

  • truncate(value: string, maxLength: number, suffix?: string): string
  • Parameters

    • value: string
    • maxLength: number
    • Default value suffix: string = "…"

    Returns string

Static uppercaseFirstLetter

  • uppercaseFirstLetter(str: string): string
  • Parameters

    • str: string

    Returns string

Legend

  • Constructor
  • Method
  • Property
  • Static method

Generated using TypeDoc