common_strings | ui-router-ng2
Options
Menu

Module common_strings

Functions that manipulate strings

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

Index

Variables

stringifyPatternFn: function = null

Type declaration

    • (val: any): string
    • Parameters

      • val any

      Returns string

Functions

  • _fromJson(json: string): any
  • _toJson(obj: Obj): string
  • beforeAfterSubstr(char: string): (Anonymous function)
  • Returns a function that splits a string on a character or substring

  • functionToString(fn: Function): any
  • joinNeighborsR(acc: any[], x: any): Array<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 Array<any>


  • kebobString(camelCase: string): 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


  • promiseToString(p: Promise<any>): 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
  • stringifyPattern(value: any): string

Generated using TypeDoc