Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/object/pick

Index

Functions

Const getPropertyAtPath

  • getPropertyAtPath<T>(obj: T, path: keyof T): Record<string, any>
  • description

    Returns an object with a single property found in obj at path

    example

    getPropertyAtPath({a: {x:1}, b: {y: 5, z: 6} }, 'b') // returns {b: {y: 5, z: 6}}

    Type parameters

    • T: object

    Parameters

    • obj: T

      The object that contains the property we want to return

    • path: keyof T

      Path to the property

    Returns Record<string, any>

    Property found in obj at path

Const pick

  • pick<T>(obj: T, paths: keyof T[]): Partial<T>
  • description

    Creates an object composed of the picked object properties.

    example

    pick({ 'a': 1, 'b': '2', 'c': 3 }, ['a'. 'c']) // returns { 'a': 1, 'c': 3 }

    Type parameters

    • T: object

    Parameters

    • obj: T

      The object to pick data from

    • paths: keyof T[]

      An array of paths to pick off obj

    Returns Partial<T>

    Key value pairs found in obj from paths

Generated using TypeDoc