Options
All
  • Public
  • Public/Protected
  • All
Menu

Module string

Index

Type aliases

PadPositionValue

PadPositionValue: "start" | "end"

Internal value type for the padding position

internal

TrimPositionValue

TrimPositionValue: "start" | "end" | "all"

Internal value type for the trim position

internal

Other Functions

Private scheduleCharCode

  • scheduleCharCode(input: number | number[], scheduler: SchedulerLike): Observable<string>
  • Takes an input of char codes and returns a method that updates an subscriber with the string value from the char codes

    Parameters

    • input: number | number[]
    • scheduler: SchedulerLike

    Returns Observable<string>

Private scheduleCodePoint

  • scheduleCodePoint(input: number | number[], scheduler: SchedulerLike): Observable<string>
  • Takes an input of code points and returns a method that updates an subscriber with the string value from the code points

    Parameters

    • input: number | number[]
    • scheduler: SchedulerLike

    Returns Observable<string>

Private scheduleSingleOrArrayString

  • scheduleSingleOrArrayString(input: string | string[], scheduler: SchedulerLike): Observable<string>
  • Takes an input of string and returns a method that updates an subscriber

    Parameters

    • input: string | string[]

      The string to subscribe to

    • scheduler: SchedulerLike

    Returns Observable<string>

Private scheduleSingleOrArrayUnicode

  • scheduleSingleOrArrayUnicode(input: string | string[], form: FormType, scheduler: SchedulerLike): Observable<string>
  • Takes an input of string and returns a method that updates an subscriber

    Parameters

    • input: string | string[]

      The string to subscribe to

    • form: FormType
    • scheduler: SchedulerLike

    Returns Observable<string>

Private subscribeToCharCode

  • subscribeToCharCode(input: number | number[]): (Anonymous function)
  • Takes an input of char codes and returns a method that updates an subscriber with the string value from the char codes

    Parameters

    • input: number | number[]

      The array of char codes to convert to a string

    Returns (Anonymous function)

Private Const subscribeToCodePoint

  • subscribeToCodePoint(input: number | number[]): (Anonymous function)
  • Takes an input of code points and returns a method that updates an subscriber with the string value from the code points

    Parameters

    • input: number | number[]

      The array of char codes to convert to a string

    Returns (Anonymous function)

Private Const subscribeToSingleOrArrayString

  • subscribeToSingleOrArrayString(input: string | string[]): (Anonymous function)
  • Takes an input of number and returns a method that updates an subscriber

    Parameters

    • input: string | string[]

      The number to subscribe to

    Returns (Anonymous function)

Private Const subscribeToSingleOrArrayUnicode

  • subscribeToSingleOrArrayUnicode(input: string | string[], form: FormType): (Anonymous function)

RxJS String Creation Functions

concat

  • concat(...args: string[]): MonoTypeOperatorFunction<string>
  • concat(strings: ObservableInput<string[]>): MonoTypeOperatorFunction<string>
  • concat(strings: string[]): MonoTypeOperatorFunction<string>
  • The concat operator can be used with an Observable string value and returns string concatenated with one or more strings passed as arguments This operator is based on String.prototype.concat

    example
    // With Arguments
    fromString('Mary')
     .pipe(concat(' ', 'had a little', ' ', 'lamb'))
     .subscribe(console.log) // 'Mary had a little lamb'

    Parameters

    • Rest ...args: string[]

      Additional strings as list of arguments

    Returns MonoTypeOperatorFunction<string>

    String that is a concatenation of the original string and new values

  • example
    // With Arguments
    fromString('Mary')
     .pipe(concat(of([' ', 'had a little', ' ', 'lamb'])))
     .subscribe(console.log) // 'Mary had a little lamb'
    category

    RxJS String Creation

    Parameters

    • strings: ObservableInput<string[]>

      Observable array of strings

    Returns MonoTypeOperatorFunction<string>

    String that is a concatenation of the original string and new values

  • example
    // With Array
    fromString('Mary')
     .pipe(concat([' ', 'had a little', ' ', 'lamb']))
     .subscribe(console.log) // 'Mary had a little lamb'

    Parameters

    • strings: string[]

      Additional strings as an array

    Returns MonoTypeOperatorFunction<string>

fromCharCode

  • fromCharCode(input: number, scheduler?: SchedulerLike): Observable<string>
  • fromCharCode(input: number[], scheduler?: SchedulerLike): Observable<string>
  • The fromCharCode operator is used to create an Observable string from a number or number array of code points using String.fromCharCode

    Unlike the from operator when passing an array of numbers to this operator it will generate a single string from the passed arguments

    example
    fromCharCode(65).subscribe(console.log) // 'A'

    Parameters

    • input: number

      A char code number to turn into a string

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from a character code

  • example
    fromCharCode([65, 66, 67, 68]).subscribe(console.log) // 'ABCD'
    category

    RxJS String Creation

    Parameters

    • input: number[]

      An array of char code numbers to turn into a string

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from an an array of character codes

fromCodePoint

  • fromCodePoint(input: number, scheduler?: SchedulerLike): Observable<string>
  • fromCodePoint(input: number[], scheduler?: SchedulerLike): Observable<string>
  • The fromCodePoint operator is used to create an Observable string from a number or number array of code points using String.fromCodePoint

    Unlike the from operator when passing an array of numbers to this operator it will generate a single string from the passed arguments

    example
    fromCharCode(9733).subscribe(console.log) // '★'

    Parameters

    • input: number

      A code point number to turn into a string

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from a code point

  • example
    fromCharCode([9731, 9733, 9842]).subscribe(console.log) // '☃★♲'
    category

    RxJS String Creation

    Parameters

    • input: number[]

      An array of code point numbers to turn into a string

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from an an array of code points

fromString

  • fromString(input: string, scheduler?: SchedulerLike): Observable<string>
  • fromString(input: string[], scheduler?: SchedulerLike): Observable<string>
  • The fromString operator is used to create an Observable string from a passed string value or array of string values.

    example
    fromString('Foobar')..pipe(reverse()).subscribe(console.log) // 'rabooF'

    Parameters

    • input: string

      The string to create the Observable source from

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from the original string, made Observable

  • When using fromString with an array, this acts like the from operator and emits for each array item

    example
    fromString(['Foo', 'Bar'])..pipe(reverse()).subscribe(console.log) // ['ooF', 'raB']
    category

    RxJS String Creation

    Parameters

    • input: string[]

      Array of strings to create Observable values from

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from the original string, made Observable

fromUnicode

  • fromUnicode(input: string, form?: FormType, scheduler?: SchedulerLike): Observable<string>
  • fromUnicode(input: string[], form?: FormType, scheduler?: SchedulerLike): Observable<string>
  • Takes a string containing the Unicode Normalization Form and uses String.prototype.normalize to convert it to a string with unicode characters

    example
    fromUnicode('\u0041\u006d\u00e9\u006c\u0069\u0065')
     .subscribe(console.log) // Amélie

    Parameters

    • input: string

      A string of unicode characters

    • Optional form: FormType

      The Unicode Normalization Form to decode the string with

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from the decoded unicode string

  • example
    fromUnicode(['\u0041\u006d\u00e9\u006c\u0069\u0065', '\u0041\u006d\u0065\u0301\u006c\u0069\u0065'])
     .subscribe(console.log) // ['Amélie', 'Amélie']
    category

    RxJS String Creation

    Parameters

    • input: string[]

      An array of strings of unicode characters

    • Optional form: FormType

      The Unicode Normalization Form to decode the string with

    • Optional scheduler: SchedulerLike

      Optional SchedulerLike

    Returns Observable<string>

    String from the decoded unicode string

slice

  • slice(startIndex: number): MonoTypeOperatorFunction<string>
  • slice(startIndex: number, endIndex: number): MonoTypeOperatorFunction<string>
  • The slice operator can be used with an Observable string value and returns a substring of the original string.

    This operator is based on String.prototype.slice

    example
    fromString('Mary had a little lamb')
     .pipe(slice(0, 4))
     .subscribe(console.log) // 'Mary'

    Parameters

    • startIndex: number

      The start index for the substring

    Returns MonoTypeOperatorFunction<string>

    String that is a substring of the original string value

  • example
    fromString('Mary had a little lamb')
     .pipe(slice(11, 17))
     .subscribe(console.log) // 'little'
    category

    RxJS String Creation

    Parameters

    • startIndex: number

      The start index for the substring

    • endIndex: number

      Optional end index for the length of substring

    Returns MonoTypeOperatorFunction<string>

    String that is a substring of the original string value

substring

  • substring(start: number): MonoTypeOperatorFunction<string>
  • substring(start: number, end: number): MonoTypeOperatorFunction<string>
  • The substring operator can be used with an Observable string value and returns a substring based on the passed start and end value

    This operator is based on String.prototype.substring

    example
    fromString('Mary had a little lamb')
     .pipe(substring(12))
     .subscribe(console.log) // 'little lamb'

    Parameters

    • start: number

      Index of the string where to start the substring

    Returns MonoTypeOperatorFunction<string>

    String that is a substring of the original string

  • example
    fromString('Mary had a little lamb')
     .pipe(substring(0, 4))
     .subscribe(console.log) // 'Mary'
    category

    RxJS String Creation

    Parameters

    • start: number

      Index of the string where to start the substring

    • end: number

      Optional end index of the substring, if not passed it will use the string length

    Returns MonoTypeOperatorFunction<string>

    String that is a substring of the original string

RxJS String Filter Functions

filterEndsWith

  • filterEndsWith(character: string): MonoTypeOperatorFunction<string>
  • filterEndsWith(character: string, length: number): MonoTypeOperatorFunction<string>
  • The filterEndsWith operator can be used with an Observable string value and returns a string value if the string of length ends with the passed character using String.prototype.endsWith

    • If you need to get the boolean value instead of value use endsWith
    example
    fromString(['test', 'testing'])
     .pipe(filterEndsWith('g'))
     .subscribe(console.log) // ['testing']

    Parameters

    • character: string

      The character to check the string ends with

    Returns MonoTypeOperatorFunction<string>

    String that passes the equality check of String.prototype.endsWith

  • example
    fromString(['test', 'testing'])
     .pipe(filterEndsWith('t', 4))
     .subscribe(console.log) // ['test', 'testing']
    category

    RxJS String Filter

    Parameters

    • character: string

      The character to check the string ends with

    • length: number

      Optional length of the string to check

    Returns MonoTypeOperatorFunction<string>

    String that passes the equality check of String.prototype.endsWith

filterIncludes

  • filterIncludes(searchStr: string): MonoTypeOperatorFunction<string>
  • The filterIncludes operator can be used with an Observable string value and returns a string value if the string contains the includes parameter

    remarks

    Based on String.prototype.includes If you need to get the boolean quality instead of value use includes

    example
    from(['test', 'foobar', 'testing'])
     .pipe(filterIncludes('test'))
     .subscribe(console.log) // ['test', 'testing']

    Parameters

    • searchStr: string

      The value to check the string includes

    Returns MonoTypeOperatorFunction<string>

    String that passes the equality check of String.prototype.includes

filterStartsWith

  • filterStartsWith(character: string): MonoTypeOperatorFunction<string>
  • filterStartsWith(character: string, length: number): MonoTypeOperatorFunction<string>
  • The filterStartsWith operator can be used with an Observable string value and returns a string value if the string of length starts with the passed character using String.prototype.startsWith

    • If you need to get the boolean value instead of value use startsWith
    example
    fromString(['test', 'testing', 'foobar'])
     .pipe(filterStartsWith('t'))
     .subscribe(console.log) // ['test', 'testing']

    Parameters

    • character: string

      The character to check the string starts with

    Returns MonoTypeOperatorFunction<string>

    String that passes the equality check of String.prototype.startsWith

  • example
    fromString(['test', 'testing', 'amazing'])
     .pipe(filterStartsWith('i', 4))
     .subscribe(console.log) // ['testing', 'amazing']
    category

    RxJS String Filter

    Parameters

    • character: string

      The character to check the string starts with

    • length: number

      Optional length of the string to check

    Returns MonoTypeOperatorFunction<string>

    String that passes the equality check of String.prototype.startsWith

RxJS String Formatting Functions

padEnd

  • padEnd(maxLength: number, fillString?: string): MonoTypeOperatorFunction<string>
  • The padEnd operator can be used with an Observable string value and returns a string with it's end padded

    This operator is based on String.prototype.padEnd

    example
    fromString('12345')
     .pipe(padEnd(7, '.'))
     .subscribe(console.log) // '12345..'

    Parameters

    • maxLength: number

      Pads the string to this length

    • Optional fillString: string

      Optional string to fill in the padding

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with space padding

padStart

  • padStart(maxLength: number, fillString?: string): MonoTypeOperatorFunction<string>
  • The padStart operator can be used with an Observable string value and returns a string with it's start padded This operator is based on String.prototype.padStart

    example
    fromString('12345')
     .pipe(padStart(7, '.'))
     .subscribe(console.log) // '..12345'

    Parameters

    • maxLength: number

      Pads the string to this length

    • Optional fillString: string

      Optional string to fill in the padding

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with space padding

padString

  • padString(padPosition: PadPositionValue, maxLength: number): MonoTypeOperatorFunction<string>
  • padString(padPosition: PadPositionValue, maxLength: number, fillString: string): MonoTypeOperatorFunction<string>
  • The padString operator can be used with an Observable string value and returns a padded string based on the passed position and length

    This operator is based on both String.prototype.padStart and String.prototype.padStart but provide a single API via PadPosition option

    example
    fromString('12345')
     .pipe(padString('start', 7))
     .subscribe(console.log) // '  12345'

    Parameters

    • padPosition: PadPositionValue

      The position to pad the string at, either 'start' or 'end'

    • maxLength: number

      Pads the string to this length

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with deafult space padding

  • example
    fromString('12345')
     .pipe(padString('end', 10, 'X'))
     .subscribe(console.log) // '12345XXXXX'
    category

    RxJS String Formatting

    Parameters

    • padPosition: PadPositionValue

      The position to pad the string at, either 'start' or 'end'

    • maxLength: number

      Pads the string to this length

    • fillString: string

      Character or character to use for padding

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with padding using the fillString

repeat

  • repeat(count: number): MonoTypeOperatorFunction<string>
  • repeat(count: number, separator: string): MonoTypeOperatorFunction<string>
  • The repeat operator can be used with an Observable string value and returns a string that is reversed.

    This operator is based on String.prototype.matchAll

    Parameters

    • count: number

      The number of times to repeat the string

      • @example
        fromString('foobar')
        .pipe(repeat(5))
        .subscribe(console.log) // 'foobarfoobarfoobarfoobarfoobar'

    Returns MonoTypeOperatorFunction<string>

    String that is a repeat of the source string, repeated by the passed count

  • This method is a custom implementation allowing an optional separator to be passed which is useful when creating some string values

    category

    RxJS String Formatting

    Parameters

    • count: number

      The number of times to repeat the string

    • separator: string

      Separator when concatenating strings

      • @example
        fromString('foobar')
        .pipe(repeat(5, ','))
        .subscribe(console.log) // 'foobar,foobar,foobar,foobar,foobar'

    Returns MonoTypeOperatorFunction<string>

    String that is a repeat of the source string with a separator, repeated by the passed count

replace

  • replace(pattern: string, replacement: string): MonoTypeOperatorFunction<string>
  • replace(pattern: RegExp, replacement: string): MonoTypeOperatorFunction<string>
  • The replace operator can be used with an Observable string value and returns a string with the text replaced via the passed pattern

    This operator is based on String.prototype.replace

    example
    fromString('Mary had a little lamb')
     .pipe(replace('lamb', 'dog'))
     .subscribe(console.log) // ['Mary had a little dog']

    Parameters

    • pattern: string

      A string to find in the Observable string to replace

    • replacement: string

      The replacement string

    Returns MonoTypeOperatorFunction<string>

    String with text replaced based on pattern and replacement string

  • example
    fromString('You get a car, you get a car, YOU GET A CAR')
     .pipe(replace(/\b(\w*car\w*)\b/g, 'bee'))
     .subscribe(console.log) // 'You get a bee, you get a bee, YOU GET A CAR'
    category

    RxJS String Formatting

    Parameters

    • pattern: RegExp

      A regular expression to match on the Observable string to replace

    • replacement: string

      The replacement string

    Returns MonoTypeOperatorFunction<string>

    String with text replaced based on pattern and replacement string

reverse

  • reverse(): MonoTypeOperatorFunction<string>
  • The reverse operator can be used with an Observable string value and returns a string that is reversed

    remarks

    This is a custom operator for this library and uses a method found on 1loc

    example
    fromString('emordnilaP')
     .pipe(reverse())
     .subscribe(console.log) // 'Palindrome'

    Returns MonoTypeOperatorFunction<string>

    String that is reversed

titleize

  • titleize(): MonoTypeOperatorFunction<string>
  • titleize(locales: string | string[]): MonoTypeOperatorFunction<string>
  • titleize(locales: string | string[], separator: any): MonoTypeOperatorFunction<string>
  • The titleize operator can be used with an Observable string value and returns a string that is titleized (first letter of each word uppercase)

    String.prototype.toLocaleUpperCase to handle upper case so supports locales.

    remarks

    This is a custom operator for this library and uses a method found on 1loc, it uses

    example
    fromString('Mary had a little lamb')
     .pipe(titleize())
     .subscribe(console.log) // 'Mary Had A Little Lamb'

    Returns MonoTypeOperatorFunction<string>

    String that is titleized

  • example
    fromString('Mary had ä little lamb')
     .pipe(titleize('de-DE'))
     .subscribe(console.log) // 'Mary Had Ä Little Lamb'
    category

    RxJS String Formatting

    Parameters

    • locales: string | string[]

      Locales to pass for string formatting

    Returns MonoTypeOperatorFunction<string>

    String that is titleized

  • example
    fromString('john,paul,john,ringo')
     .pipe(titleize('en-GB', ','))
     .subscribe(console.log) // 'John,Paul,John,Ringo'
    category

    RxJS String Formatting

    Parameters

    • locales: string | string[]

      Locales to pass for string formatting

    • separator: any

      Separator if the string isn't using space characters

    Returns MonoTypeOperatorFunction<string>

    String that is titleized with custom separator

toLowerCase

  • toLowerCase(): MonoTypeOperatorFunction<string>
  • toLowerCase(locales: string | string[]): MonoTypeOperatorFunction<string>
  • The toLowerCase operator can be used with an Observable string value and returns a string changed to all lower case characters

    This operator is based on both String.prototype.toLocaleLowerCase rather than toLowerCase as this provides support for localisation of string

    example
    fromString('APPLE')
     .pipe(toLowerCase())
     .subscribe(console.log) // 'apple'

    Returns MonoTypeOperatorFunction<string>

    String that is converted to lower case

  • example
    fromString('ÄPFEL')
     .pipe(toLowerCase('de-DE'))
     .subscribe(console.log) // 'äpfel'
    category

    RxJS String Formatting

    Parameters

    • locales: string | string[]

      Optional locales to pass for string formatting

    Returns MonoTypeOperatorFunction<string>

    String that is converted to lower case with passed locale

toUpperCase

  • toUpperCase(): MonoTypeOperatorFunction<string>
  • toUpperCase(locales: string | string[]): MonoTypeOperatorFunction<string>
  • The toUpperCase operator can be used with an Observable string value and returns a string changed to all upper case characters

    This operator is based on both String.prototype.toLocaleUpperCase rather than toUpperCase as this provides support for localisation of string

    example
    fromString('apple')
     .pipe(toUpperCase())
     .subscribe(console.log) // 'APPLE'

    Returns MonoTypeOperatorFunction<string>

    String that is converted to upper case

  • example
    fromString('äpfel')
     .pipe(toUpperCase('de-DE'))
     .subscribe(console.log) // 'ÄPFEL'
    category

    RxJS String Formatting

    Parameters

    • locales: string | string[]

      Optional locales to pass for string formatting

    Returns MonoTypeOperatorFunction<string>

    String that is converted to upper case with passed locale

trim

  • trim(): MonoTypeOperatorFunction<string>
  • The trimRight operator can be used with an Observable string value and returns a string trimmed on the right

    This operator is based on String.prototype.trimRight

    example
    fromString('     12345     ')
     .pipe(trim())
     .subscribe(console.log) // '12345'

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with all surrounding white space trimmed

trimLeft

  • trimLeft(): MonoTypeOperatorFunction<string>
  • The trimLeft operator can be used with an Observable string value and returns a string trimmed on the left

    This operator is based on String.prototype.trimLeft

    example
    fromString('     12345     ')
     .pipe(trimLeft())
     .subscribe(console.log) // '12345     '

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with white space to the left trimmed

trimRight

  • trimRight(): MonoTypeOperatorFunction<string>
  • The trimRight operator can be used with an Observable string value and returns a string trimmed on the right

    This operator is based on String.prototype.trimRight

    example
    fromString('     12345     ')
     .pipe(trimRight())
     .subscribe(console.log) // '     12345'

    Returns MonoTypeOperatorFunction<string>

    String that is formatted with white space to the right trimmed

trimString

  • trimString(): MonoTypeOperatorFunction<string>
  • trimString(position: TrimPositionValue): MonoTypeOperatorFunction<string>
  • The trimString operator can be used with an Observable string value and returns a trimmed string

    This operator is based on String.prototype.trim, trimStart and trimEnd but provide a single API via TrimPosition option

    example
    fromString('     12345     ')
     .pipe(trimString())
     .subscribe(console.log) // '12345'

    Returns MonoTypeOperatorFunction<string>

    String that is trimmed based on the TrimPosition 'all' option

  • example
    fromString('12345     ')
     .pipe(trimString('start'))
     .subscribe(console.log) // '12345     '
    example
    fromString('     12345     ')
     .pipe(trimString('end'))
     .subscribe(console.log) // '     12345'
    category

    RxJS String Formatting

    Parameters

    • position: TrimPositionValue

      The position to trim the string from, either 'start', 'end' or 'all'

    Returns MonoTypeOperatorFunction<string>

    String that is trimmed based on the TrimPosition option

RxJS String Map Functions

mapCharCode

  • mapCharCode(): OperatorFunction<number | number[], string>
  • The mapCharCode operator can be used with an Observable a number or array of numbers that represent character codes, and returns a string value

    remarks

    Based on String.fromCharCode

    example
    of(65)
     .pipe(mapCharCode())
     .subscribe(console.log) // 'A'
    example
    of([65, 66, 67, 68])
     .pipe(mapCharCode())
     .subscribe(console.log) // 'ABCD'

    Returns OperatorFunction<number | number[], string>

    String from an array of character codes

mapCodePoint

  • mapCodePoint(): OperatorFunction<number | number[], string>
  • The mapCodePoint operator can be used with an Observable number or array of numbers that represent character code points, and returns a string value

    Based on String.fromCodePoint

    example
    of(9733)
     .pipe(mapCodePoint())
     .subscribe(console.log) // '★'
    example
    of([9731, 9733, 9842])
     .pipe(mapCodePoint())
     .subscribe(console.log) // '☃★♲'

    Returns OperatorFunction<number | number[], string>

    String from a code point or an array of code points

normalize

  • normalize(form?: FormType): MonoTypeOperatorFunction<string>
  • Takes a string containing the Unicode Normalization Form and uses String.prototype.normalize to convert it to a string with unicode characters

    example
    fromString('\u0041\u006d\u00e9\u006c\u0069\u0065')
     .pipe(normalize(FormType.NFC))
     .subscribe(console.log) // Amélie

    Parameters

    • Optional form: FormType

      The Unicode Normalization Form to decode the string with

    Returns MonoTypeOperatorFunction<string>

    String from the decoded unicode string

RxJS String Query Functions

charAt

  • charAt(position: number): MonoTypeOperatorFunction<string>
  • The charAt operator can be used with an Observable string value and returns the ASCII character at the passed position. Based on String.prototype.charAt

    example
    fromString('AbCdE')
     .pipe(charAt(4))
     .subscribe(console.log) // 'E'

    Parameters

    • position: number

      The character position to get a character from, starts from 0

    Returns MonoTypeOperatorFunction<string>

    String character located at the passed position

charCodeAt

  • charCodeAt(position: number): OperatorFunction<string, number>
  • The charCodeAt operator can be used with an Observable string value and returns a number of the ASCII code for the character Based on String.prototype.charCodeAt

    example
    fromString('abcde')
     .pipe(charCodeAt(4))
     .subscribe(console.log) // 101

    Parameters

    • position: number

      The character position to get a character code from, starts from 0

    Returns OperatorFunction<string, number>

    Number of the character code from the passed string position

codePointAt

  • codePointAt(position: number): OperatorFunction<string, number>
  • The codePointAt operator can be used with an Observable string value and returns the code point of a character at the passed position. Based on String.prototype.codePointAt

    example
    fromString(['☃★♲'])
     .pipe(codePointAt(1))
     .subscribe(console.log) // 9733

    Parameters

    • position: number

      The character position to get a code point from, starts from 0

    Returns OperatorFunction<string, number>

    Number of the code point from the passed string position

endsWith

  • endsWith(character: string): OperatorFunction<string, boolean>
  • endsWith(character: string, length: number): OperatorFunction<string, boolean>
  • The endsWith operator can be used with an Observable string value and returns a boolean value if the string of length ends with the passed character using String.prototype.endsWith

    • If you need to get the string value instead of value use filterEndsWith
    example
    fromString(['test', 'testing'])
     .pipe(endsWith('g'))
     .subscribe(console.log) // [false, true]

    Parameters

    • character: string

      The character to check the string ends with

    Returns OperatorFunction<string, boolean>

    Boolean that passes the equality check of String.prototype.endsWith

  • example
    fromString(['test', 'testing'])
     .pipe(endsWith('t', 4))
     .subscribe(console.log) // [true, true]
    category

    RxJS String Query

    Parameters

    • character: string

      The character to check the string ends with

    • length: number

      Optional length of the string to check

    Returns OperatorFunction<string, boolean>

    Boolean that passes the equality check of String.prototype.endsWith

includes

  • includes(searchStr: string): OperatorFunction<string, boolean>
  • The includes operator can be used with an Observable string value and returns a boolean value if the string includes the passed value string. Based on String.prototype.includes

    remarks

    If you need to get the string value instead of boolean use filterIncludes

    example
    fromString(['test', 'testing', 'foobar'])
     .pipe(includes('test'))
     .subscribe(console.log) // [true, true, false]

    Parameters

    • searchStr: string

      The value to check if the string includes this

    Returns OperatorFunction<string, boolean>

    Boolean value if the string passes the equality check of String.prototype.includes

indexOf

  • indexOf(searchStr: string): OperatorFunction<string, number>
  • indexOf(searchStr: string, start: number): OperatorFunction<string, number>
  • The indexOf operator can be used with an Observable string value and returns the index number of the string passed, with optional start index Based on String.prototype.indexOf

    example
    fromString('foobar barfoo')
     .pipe(indexOf('foo'))
     .subscribe(console.log) // 0

    Parameters

    • searchStr: string

      The value to search for in the string

    Returns OperatorFunction<string, number>

    Index of the location where the string starts

  • example
    fromString('foobar barfoo')
     .pipe(indexOf('foo', 1))
     .subscribe(console.log) // 10
    category

    RxJS String Query

    Parameters

    • searchStr: string

      The value to search for in the string

    • start: number

      Start position from 0 being the beginning of the string

    Returns OperatorFunction<string, number>

    Index of the location where the string starts

lastIndexOf

  • lastIndexOf(searchStr: string): OperatorFunction<string, number>
  • lastIndexOf(searchStr: string, fromIndex: number): OperatorFunction<string, number>
  • The lastIndexOf operator can be used with an Observable string value and returns the index number of the string passed, with optional from index Based on String.prototype.lastIndexOf

    example
    fromString('foobar barfoo')
     .pipe(lastIndexOf('foo'))
     .subscribe(console.log) // 10

    Parameters

    • searchStr: string

      The value to search for in the string

    Returns OperatorFunction<string, number>

    Index of the location where the string starts

  • example
    fromString('foobar barfoo')
     .pipe(indexOf('foo', 2))
     .subscribe(console.log) // 0
    category

    RxJS String Query

    Parameters

    • searchStr: string

      The value to search for in the string

    • fromIndex: number

      The index of the last character in the string to be considered as the beginning of a match.

    Returns OperatorFunction<string, number>

    Index of the location where the string starts

match

  • match(pattern: string): OperatorFunction<string, RegExpMatchArray>
  • match(pattern: RegExp): OperatorFunction<string, RegExpMatchArray>
  • The match operator can be used with an Observable string value and returns an array-like RegExpMatchArray

    This operator is based on String.prototype.match

    example
    fromString('Mary had a little lamb')
     .pipe(match('little'))
     .subscribe(result => console.log(Array.from(result))) // ['little']

    Parameters

    • pattern: string

      A string value to match in the string

    Returns OperatorFunction<string, RegExpMatchArray>

    RegExpMatchArray that contains one or more results from the match

  • example
    fromString('Mary had a Little Lamb')
     .pipe(match(/[A-Z]/g))
     .subscribe(result => console.log(Array.from(result))) // ['M', 'L', 'L']
    category

    RxJS String Query

    Parameters

    • pattern: RegExp

      A RegExp to match in the string

    Returns OperatorFunction<string, RegExpMatchArray>

    RegExpMatchArray that contains one or more results from the match

matchAll

  • matchAll(pattern: RegExp): OperatorFunction<string, RegExpMatchArray[]>
  • The matchAll operator can be used with an Observable string value and returns an array-like RegExpMatchArray including capturing groups

    This operator is based on String.prototype.matchAll

    example
    fromString('table football, foosball')
     .pipe(matchAll(new RegExp('foo[a-z]*', 'g'))
     .subscribe(result => console.log(Array.from(result))) // [ 'football', 'foosball' ]

    Parameters

    • pattern: RegExp

      A RegExp to match in the string

    Returns OperatorFunction<string, RegExpMatchArray[]>

    RegExpMatchArray that contains one or more results from the match

search

  • search(pattern: string): OperatorFunction<string, number>
  • search(pattern: RegExp): OperatorFunction<string, number>
  • The search operator can be used with an Observable string value and returns the start index of a search result

    This operator is based on String.prototype.matchAll

    example
    fromString('table football, foosball')
     .pipe(matchAll(new RegExp('foo[a-z]*', 'g'))
     .subscribe(result => console.log(Array.from(result))) // [ 'football', 'foosball' ]

    Parameters

    • pattern: string

      A RegExp to match in the string

    Returns OperatorFunction<string, number>

    RegExpMatchArray that contains one or more results from the match

  • Parameters

    • pattern: RegExp

    Returns OperatorFunction<string, number>

startsWith

  • startsWith(character: string): OperatorFunction<string, boolean>
  • startsWith(character: string, length: number): OperatorFunction<string, boolean>
  • The startsWith operator can be used with an Observable string value and returns a boolean value if the string of length starts with the passed character

    Based on String.prototype.startsWith

    remarks

    If you need to get the string value instead of boolean use filterStartsWith

    example
    from(['test', 'testing', 'foobar'])
     .pipe(endsWith('t'))
     .subscribe(console.log) // [true, true, false]

    Parameters

    • character: string

      The character to check the string ends with

    Returns OperatorFunction<string, boolean>

    Boolean value if the string passes the equality check of String.prototype.startsWith

  • example
    from(['test', 'testing', 'toast'])
     .pipe(endsWith('t', 3))
     .subscribe(console.log) // [true, true, false]
    category

    RxJS String Query

    Parameters

    • character: string

      The character to check the string ends with

    • length: number

      Index to use as start of string

    Returns OperatorFunction<string, boolean>

    Boolean value if the string passes the equality check of String.prototype.startsWith

RxJS String to Array Functions

split

  • split(separator: string): OperatorFunction<string, string[]>
  • split(separator: string, limit: number): OperatorFunction<string, string[]>
  • The split operator can be used with an Observable string value and returns an array of strings based on the original string split on the separator

    This operator is based on String.prototype.split

    example
    fromString('Hello|World|Foo|Bar')
     .pipe(split('|'))
     .subscribe(console.log) // ['Hello', 'World', 'Foo', 'Bar']

    Parameters

    • separator: string

      The character to split the string at

    Returns OperatorFunction<string, string[]>

    Array of strings based on the original string split by the separator

  • example
    fromString('Hello|World|Foo|Bar')
     .pipe(split('|', 2))
     .subscribe(console.log) // ['Hello', 'World', 'Foo|Bar']
    category

    RxJS String to Array

    Parameters

    • separator: string

      The character to split the string at

    • limit: number

      Optional limit for the number of times to split

    Returns OperatorFunction<string, string[]>

    Array of strings based on the original string split by the separator

Generated using TypeDoc