• Picks selected properties from the object by dot separated path, i.e. 'a.b.c'

    Type Parameters

    • T extends object

    Parameters

    • obj: T

      Original object

    • pathOrPathArray: TypeNestedKeyOf<T> | TypeNestedKeyOf<T>[]

      Property path as dot separated string, or array of paths. Example: 'a.b.c' or ['a.b.c', 'a.b.d']

    Returns {}

    obj Object with picked properties

      Example

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