Skip to content

Commit

Permalink
feat(collection: Use readonly for arguments
Browse files Browse the repository at this point in the history
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
  • Loading branch information
lambdalisue and petamoriken authored Feb 13, 2024
1 parent bad99cf commit 86b8497
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions collections/omit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* ```
*/
export function omit<T extends object, K extends keyof T>(
obj: T,
keys: K[],
obj: Readonly<T>,
keys: readonly K[],
): Omit<T, K> {
const excludes = new Set(keys);
const has = excludes.has.bind(excludes);
Expand Down
4 changes: 2 additions & 2 deletions collections/pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* ```
*/
export function pick<T extends object, K extends keyof T>(
obj: T,
keys: K[],
obj: Readonly<T>,
keys: readonly K[],
): Pick<T, K> {
return Object.fromEntries(keys.map((k) => [k, obj[k]])) as Pick<T, K>;
}

0 comments on commit 86b8497

Please sign in to comment.