Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Lists/Paths/setPath

Index

Functions

Functions

setPath

  • setPath<V>(list: List<V>, path: ListPath, value: any, separator?: string): List<V>
  • This function lets you set a given value at a path of your array. You can also set multiple keys to the same value at once if you use wildcards.

    You may use wildcards by specifying an astrix(*) as the replacement for a generic key, which will iterate over all, possible keys in the given list. You may also specify a subset of keys to return, by using braces like [key1,key2]

    NOTE: The list is directly edited! If you want immutable behaviour, clone the list first!

    Type parameters

    • V = any

    Parameters

    • list: List<V>

      The list to set the value to

    • path: ListPath

      The path to set $value at

    • value: any

      The value to set at $path in $input

    • Optional separator: string

      Default: "." Can be set to any string you want to use as separator of path parts.

    Returns List<V>

Generated using TypeDoc