Options
All
  • Public
  • Public/Protected
  • All
Menu

Some utility functions.

Index

Types

Index

Index: string | number

JSON path's index portion. We handle JSON path of "/abc/1/def" as an index array of ["abc", 1, "def"].

Entries

Const isIntStr

  • isIntStr(x: string): boolean
  • Returns true if x is an string representation of an integer value.

    example
    isIntStr("abc");  // => false
    isIntStr("123"); // => true
    isIntStr("1a"); // => false

    Parameters

    • x: string

    Returns boolean

Const normalizePath

  • normalizePath(path: string): string
  • Returns the array-index independent normalized path.

    example
    normalizePath("/abc/1/def");  // => "/abc/" + "*" + "/def"
    

    Parameters

    • path: string

    Returns string

Const appendPath

  • appendPath(base: string, path: string): string
  • Concatenates two paths, `path' can be a relative one. It roughly follows the Relative JSON path standard.

    example
    appendPath("/abc/def", "1/zzz");  // => "/abc/zzz"
    appendPath("/abc/def", "0/zzz"); // => "/abc/def/zzz"
    appendPath("/abc/def", "/zzz"); // => "/zzz"

    Parameters

    • base: string
    • path: string

    Returns string

Const normalizePathArray

  • normalizePathArray(path: Index[]): string
  • Normalizes not a string path but an array path, then returns a normalized string path.

    Parameters

    Returns string

Const pathToArray

  • pathToArray(path: string): Index[]
  • Separates a path described by a string into an Index array.

    Parameters

    • path: string

    Returns Index[]

Const typeOf

  • typeOf(x: any): string
  • A variant of `typeof', which handles null and Array appropreately.

    example
    typeOf([]);    // => 'array'
    typeOf(null); // => 'null'

    Parameters

    • x: any

    Returns string

Const isJsonValue

  • isJsonValue(x: any): boolean
  • Returns true if `x' is a json value. This is just a shallow test.

    Parameters

    • x: any

    Returns boolean

Const commonPath

  • commonPath(path1: string, path2: string): string
  • Extracts common portion of paths.

    example
    commonPath("/abc/def", "/abc/zzz");  // => "/abc"
    commonPath("/abc/def", "/abc/deX"); // => "/abc"
    commonPath("/abc", "/xxx"); // => ""
    commonPath("/abc/def/aaa", "/abc/def/bbb"); // => "/abc/def"

    Parameters

    • path1: string
    • path2: string

    Returns string

Const normalizeQuery

  • normalizeQuery(obj: Record<string, string>, omitEmptyParam: boolean): Record<string, string>
  • Builds a query string from `obj'.

    Parameters

    • obj: Record<string, string>
    • omitEmptyParam: boolean

    Returns Record<string, string>

Other

showText

Renames and re-exports default

Generated using TypeDoc