Skip to content

pick

Pick a list of properties from an object into a new object. ⚠️ When used with a predicate function, `pick` is potentially unsafe, because of partial type matching performed by TypeScript. If you pass an object with more properties than its TypeScript type has listed, the `value` and `key` parameter types of your callback will be inaccurate.

Usage

const a = { a: 1, b: 2, c: 3 };
pick(a, ["a", "c"]); // => { a: 1, c: 3 }
pick(a, (value, key) => value > 1); // => { b: 2, c: 3 }

Installation

Terminal window
npx atmx add helper pick