Includes all the property paths from the given object for the given list of paths.
The source object can Plain Object
or Array
.
Syntax
import { pick } from '@opentf/std';
pick(obj: object, ...paths: (string | unknown[])[])
Examples
pick({ a: 1, b: 2 }, 'a') //=> { a: 1 }
pick([1, 2, 3], '0') //=> [1]
pick({ a: { b: { c: 1 }, d: null, e: [10, 20, 30] } }, 'a.b', ['a', 'e', '2'])
//=> {
// a: { b: { c: 1 } },
// e: [30]
// }