For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/pick.md.

pick (Functional Programming) es-toolkit

Creates a function that keeps only the given keys of an object. Use it with pipe.

const result = pipe(obj, pick(keys));
Info

Prefer the original es-toolkit pick in ordinary code. Use this fp variant when composing transformations with pipe.

Usage

pick returns a new object that contains only the specified keys from the input object. Keys that are not present on the input are skipped.

import { pick, pipe } from 'es-toolkit/fp';

pipe({ a: 1, b: 2, c: 3 }, pick(['a', 'c'])); // => { a: 1, c: 3 }

Parameters

keysreadonly K[]required

The keys to copy into the new object.

Returns

A function that maps an object T to a new object with only the picked keys.

(obj: T) => Pick<T, K>
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.