Skip to content

Commit

Permalink
docs: update pick and omit descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsdaniels committed Apr 29, 2024
1 parent 52ed862 commit 4be212f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
13 changes: 3 additions & 10 deletions packages/essentials/utilities/object/omit.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
/**
* The code below is a function that takes an object and an array of keys,
* and returns a new object that has the same keys as the original object
* except for the keys found in the array. It uses Object.fromEntries() to
* convert an array of key-value pairs to an object and Object.entries() to
* convert an object to an array of key-value pairs.
* @param record - An object
* @param keys - Array of keys to omit
* @returns
* omit({ a: 1, b: 2, c: 3 }, ["a"]); // { b: 2, c: 3 }
* Copies and object, omitting the specified keys and keeping the rest.
*
* @example omit({ a: 1, b: 2, c: 3 }, ["a"]) = { b: 2, c: 3 }
*/

export function omit<T extends object, K extends keyof T>(
record: T,
keys: K[],
Expand Down
9 changes: 3 additions & 6 deletions packages/essentials/utilities/object/pick.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/**
* This function takes an object and an array of keys as arguments and returns a new object with only the keys from the array. The function is generic so it can be used with any type of object.
* @param record - An object
* @param keys - An array of keys to pick from the object
* @returns
* pick({ a: 1, b: 2, c: 3 }, ["a"]); // { a: 1 }
* Copies an object, keeping only the specified keys and discarding the rest.
*
* @example pick({ a: 1, b: 2, c: 3 }, ["a"]) = { a: 1 }
*/

export function pick<T extends object, K extends keyof T>(
record: T,
keys: K[],
Expand Down

0 comments on commit 4be212f

Please sign in to comment.