Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Object

Index

Functions

addToProp

  • addToProp<T, K>(obj: Record<K, T | T[]>, key: K, value: T, overwrite?: boolean): Record<K, T | T[]>
  • If key already exists in obj, turns respective value into array and pushes value onto the array. Else, adds "normal" key-value pair as property. If overwrite is true, always overwrites existing value with new value without turning it into array.

    Type parameters

    • T

    • K: string

    Parameters

    • obj: Record<K, T | T[]>
    • key: K
    • value: T
    • Optional overwrite: boolean

    Returns Record<K, T | T[]>

filter

  • filter<T>(obj: Record<string, T>, func: function): Record<string, T>
  • Returns a new filtered object that only contains those properties of the initial object where func returned true.

    Does not traverse nested objects!

    Type parameters

    • T

    Parameters

    • obj: Record<string, T>
    • func: function
        • (value: T, key?: string): boolean
        • Parameters

          • value: T
          • Optional key: string

          Returns boolean

    Returns Record<string, T>

forEachProperty

  • forEachProperty<T, K>(input: Record<K, T>, func: function): Record<K, T>
  • Iterates over all properties in an object and executes func on each.

    Type parameters

    • T

    • K: string

    Parameters

    • input: Record<K, T>
    • func: function
        • (value: T, key?: K): void
        • Parameters

          • value: T
          • Optional key: K

          Returns void

    Returns Record<K, T>

invert

  • invert<K>(obj: Record<K, string>): Record<string, K>
  • Returns a new object with the original object's keys and values inverted. The original object's values must therefore be implicitly convertable to type string.

    Type parameters

    • K: string

    Parameters

    • obj: Record<K, string>

    Returns Record<string, K>

mapProperties

  • mapProperties<T, O, K>(input: Record<K, T>, func: function): Record<K, O>
  • Iterates over all properties in an object and executes func on each.

    Returns a new object with the same keys as the input object and the values as result of the func.

    Type parameters

    • T

    • O

    • K: string

    Parameters

    • input: Record<K, T>
    • func: function
        • (value: T, key?: K): O
        • Parameters

          • value: T
          • Optional key: K

          Returns O

    Returns Record<K, O>

stripMaskDeep

  • Returns a new object where all properties with a boolean value of false are stripped recursively.

    Parameters

    Returns IRecObj<boolean>

stripProps

  • stripProps<T>(obj: Record<string, T>, props: string[]): Record<string, T>
  • Creates a copy of original object in which all key-value pairs matching the passed props are removed.

    Type parameters

    • T

    Parameters

    • obj: Record<string, T>
    • props: string[]

    Returns Record<string, T>

subset

  • subset<T, O>(obj: Record<string, T>, maskObject: Record<string, O>): Record<string, T>
  • Returns properties of obj whose keys are also present in subsetObj as a new object.

    Does not traverse nested objects!

    Type parameters

    • T

    • O

    Parameters

    • obj: Record<string, T>
    • maskObject: Record<string, O>

    Returns Record<string, T>

Generated using TypeDoc