Documentation
@tsly/obj
pickKeys

pickKeys

Reduces the wrapped object to only have the specified keys

import { obj } from "@tsly/obj";
 
const person = {
  first: "John",
  last: "Smith",
  age: 23,
  state: "NY",
};
 
const name = obj(person).dropKeys(["first", "last"]).take();
 
console.log(name); // { "first": "John", "last": "Smith" }
console.log(person); // { "first": "John", "last": "Smith", "age": 23, "state": "NY" }

Edit on CodeSandbox (opens in a new tab)