Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Object

Index

Functions

Const conditionallyGroupObjectProperties

  • conditionallyGroupObjectProperties<T>(values: T, ...conditions: PropertyCondition<T>[]): Partial<T>[]
  • Function that receivs an object and creates an array out of that object properties. The properties in the end result array are chosen based on the checks passed. For instance, if we passed in an object of obj = {a : 1, b:2, c:3}, and introduced checks to only include properties with the keys a and b, the end result would look like this: [{a:1}, {b:2}]

    Type parameters

    • T: Record<string, any>

      extends Record<string, any>

    Parameters

    Returns Partial<T>[]

Const convertDotNotationToArrayOfPath

  • convertDotNotationToArrayOfPath(path: string): PathArray
  • Function that peceives the path as a string and generates an array of paths out of it. This output could be an empty array if the input string is empty.

    Parameters

    • path: string

    Returns PathArray

Const getFrom

  • getFrom(values: object, path: string | PathArray): any
  • From a given object get the value defined at a given path, denoted by dot notation or an array. This function serves as a wrapper function for the getFromBaseFunction. The purpose of it is to provide with high-level formatting.

    Parameters

    Returns any

Const getFromBaseFunction

  • getFromBaseFunction(values: object, path: PathArray): any
  • From a given object get the value defined at a given path.

    Parameters

    Returns any

hasChangesShallow

  • hasChangesShallow<T>(object: T, toUpdate: Partial<T>): boolean
  • Check if specific fields in an object will be updated

    Type parameters

    • T: object

    Parameters

    • object: T

      Original object

    • toUpdate: Partial<T>

      Updated value

    Returns boolean

    boolean

Const mergeIfChanged

  • mergeIfChanged(object: object, value: object): object
  • Merge either an object or an array together

    Parameters

    • object: object
    • value: object

    Returns object

Const normalisePath

  • This function is responsible for checking the type of the path and deciding the correct operation. If that path given is string, then it will be converted to array of paths using our helper function. If the path given is not string, it simply returns the path.

    Parameters

    Returns PathArray

Const removeFrom

  • removeFrom(values: object, path: string | PathArray): object
  • Immutably removes an item from an object or array at a given path, denoted by dot notation or an array.

    If the item is already removed nothing is changed. i.e. values is returned.

    Parameters

    Returns object

Const removeFromBaseFunction

  • removeFromBaseFunction(values: object, path: PathArray): object
  • Immutably removes an item from an object or array at a given path

    Parameters

    Returns object

Const setIn

  • setIn(values: object, path: string | PathArray, value: any, mergeAtTarget?: boolean): any
  • Immutably sets a value in an object or array at a given path, denoted by dot notation or an array.

    If the value is already identical nothing is changed. i.e. values is returned. This function is similar to Lodash 'set', however it also;

    • will make the path if required
    • will also merge a given object or array at the path if desired

    Parameters

    • values: object
    • path: string | PathArray
    • value: any
    • Default value mergeAtTarget: boolean = false

    Returns any

Const setInBaseFunction

  • setInBaseFunction(values: any, path: PathArray, value: any, mergeAtTarget: boolean): any
  • Immutably sets a value in an object or array at a given path.

    Parameters

    • values: any
    • path: PathArray
    • value: any
    • mergeAtTarget: boolean

    Returns any

Generated using TypeDoc