Skip to content

pick

Picks the specified keys from an object and returns a new object containing only those key-value pairs.

Import

import { pick } from "@aa-sdk/core";

Usage

import { pick } from "@aa-sdk/core";
 
const picked = pick(
  {
    foo: "foo",
    bar: "bar",
  },
  ["foo"]
); // { foo: "foo" }

Parameters

obj

Record<string, unknown> The object from which to pick keys

keys

string|string[] A single key or an array of keys to pick from the object

Returns

Record<string, unknown> A new object containing only the picked key-value pairs