Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Array

Index

Functions

Const buildArray

  • buildArray<T>(length: number, valueGiver: (i: number) => T): T[]
  • Build an array using a function that will give values for each given index. Can be used to create arrays of objects, ensuring each has it's own reference.

    Type parameters

    • T

    Parameters

    • length: number
    • valueGiver: (i: number) => T
        • (i: number): T
        • Parameters

          • i: number

          Returns T

    Returns T[]

doArraysHaveSameValues

  • doArraysHaveSameValues(a: any[], b: any[]): boolean
  • Function that checks if both arrays have the same values i.e. the same number of occurring values in each array

    example

    doArraysHaveSameValues(['a','a','b'], ['a','b','b']) returns false

    example

    doArraysHaveSameValues(['a','b'], ['b','a']) returns true

    Parameters

    • a: any[]
    • b: any[]

    Returns boolean

setValueInChildArray

  • setValueInChildArray<T>(values: T, recursionKey: string, newValue: any, keyToSet: string): T
  • Sets a key in all objects in an array property of the values object passed.

    Useful for setting all lines in the formik state in components that do not have access to the financial table state. (headers, etc). Performs a similar role to updateAvailableLines but not limited to operating on LineState objects.

    Type parameters

    • T: object

    Parameters

    • values: T

      The object to update the value in.

    • recursionKey: string

      The the key to recurse down to find child objects.

    • newValue: any

      The value to set all keys in the values object to.

    • keyToSet: string

      The key to set newValue to.

    Returns T

    array of strings

Generated using TypeDoc