common_strings | @uirouter/angularjs
Options
Menu

Module common_strings

Functions that manipulate strings

Although these functions are exported, they are subject to change without notice.

Index

Variables

hostRegex: RegExp = new RegExp('^(?:[a-z]+:)?//[^/]+/')
isRejection: isRejectionPromise = Rejection.isRejectionPromise
splitEqual: (Anonymous function) = beforeAfterSubstr('=')
splitHash: (Anonymous function) = beforeAfterSubstr('#')
splitQuery: (Anonymous function) = beforeAfterSubstr('?')
stringifyPattern: function = pattern([[isUndefined, val('undefined')],[isNull, val('null')],[isPromise, val('[Promise]')],[isRejection, (x: any) => x._transitionRejection.toString()],[hasToString, (x: object) => x.toString()],[isInjectable, functionToString],[val(true), identity],]) as (val: any) => string

Type declaration

    • (val: any): string
    • Parameters

      • val any

      Returns string

Functions

  • beforeAfterSubstr(char: string): (Anonymous function)
  • Returns a function that splits a string on a character or substring

  • Returns a function that splits a string on a character or substring

    Parameters

    • char string

    Returns (Anonymous function)


  • Parameters

    Returns any


  • functionToString(fn: Function): any
  • Parameters

    • fn Function

    Returns any


  • hasToString(obj: any): boolean
  • Parameters

    • obj any

    Returns boolean


  • joinNeighborsR(acc: any[], x: any): any[]
  • Reduce fn that joins neighboring strings

  • Reduce fn that joins neighboring strings

    Given an array of strings, returns a new array where all neighboring strings have been joined.

    Example:

    let arr = ["foo", "bar", 1, "baz", "", "qux" ];
    arr.reduce(joinNeighborsR, []) // ["foobar", 1, "bazqux" ]

    Parameters

    • acc any[]
    • x any

    Returns any[]


  • kebobString(camelCase: string): string
  • Parameters

    • camelCase string

    Returns string


  • maxLength(max: number, str: string): string
  • Returns a string shortened to a maximum length

  • Returns a string shortened to a maximum length

    If the string is already less than the max length, return the string. Else return the string, shortened to max - 3 and append three dots ("...").

    Parameters

    • max number
      :

      the maximum length of the string to return

    • str string
      :

      the input string

    Returns string


  • padString(length: number, str: string): string
  • Returns a string, with spaces added to the end, up to a desired str length

  • Returns a string, with spaces added to the end, up to a desired str length

    If the string is already longer than the desired length, return the string. Else returns the string, with extra spaces on the end, such that it reaches length characters.

    Parameters

    • length number
      :

      the desired length of the string to return

    • str string
      :

      the input string

    Returns string


  • splitOnDelim(delim: string): (Anonymous function)
  • Splits on a delimiter, but returns the delimiters in the array

  • Splits on a delimiter, but returns the delimiters in the array

    Example:

    var splitOnSlashes = splitOnDelim('/');
    splitOnSlashes("/foo"); // ["/", "foo"]
    splitOnSlashes("/foo/"); // ["/", "foo", "/"]

    Parameters

    • delim string

    Returns (Anonymous function)


  • stringify(o: any): string
  • Parameters

    • o any

    Returns string


  • stripLastPathElement(str: string): string
  • Parameters

    • str string

    Returns string


  • trimHashVal(str: string): string
  • Parameters

    • str string

    Returns string


Generated using TypeDoc