js-helpers

Pick

Pick (Object object, Array keys, [Boolean clone])

Returns new object with only keys from array. References preserved unless clone is provided.

Opposite of Omit.

Arguments

Object object

Any object

Array keys

Should be array of String. [String]

Boolean clone

If present will return a new object without references to object. See Clone.

Use

import { Pick } from "@taystack/js-helpers";

const obj1 = {a: 1, b: 2, c: 3};
const obj2 = Pick(obj1, ["c"]);
obj2;                                // {c: 3}

Source: @taystack/js-helpers hosted on GitHub Author: taystack