source: node_modules/es-toolkit/dist/object/omit.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * Creates a new object with specified keys omitted.
3 *
4 * This function takes an object and an array of keys, and returns a new object that
5 * excludes the properties corresponding to the specified keys.
6 *
7 * @template T - The type of object.
8 * @template K - The type of keys in object.
9 * @param {T} obj - The object to omit keys from.
10 * @param {K[]} keys - An array of keys to be omitted from the object.
11 * @returns {Omit<T, K>} A new object with the specified keys omitted.
12 *
13 * @example
14 * const obj = { a: 1, b: 2, c: 3 };
15 * const result = omit(obj, ['b', 'c']);
16 * // result will be { a: 1 }
17 */
18declare function omit<T extends Record<PropertyKey, any>, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
19/**
20 * Creates a new object with specified keys omitted.
21 *
22 * This overload supports dynamic key arrays determined at runtime,
23 * useful when working with keys from Object.keys() or similar operations.
24 *
25 * @template T - The type of object.
26 * @param {T} obj - The object to omit keys from.
27 * @param {PropertyKey[]} keys - An array of keys to be omitted from the object. Supports dynamic arrays.
28 * @returns {Partial<T>} A new object with the specified keys omitted.
29 *
30 * @example
31 * const obj = { a: 1, b: 2, c: 3 };
32 * const keysToOmit = Object.keys({ b: true, c: true }); // string[]
33 * const result = omit(obj, keysToOmit);
34 * // result will be { a: 1 }
35 */
36declare function omit<T extends Record<PropertyKey, any>>(obj: T, keys: readonly PropertyKey[]): Partial<T>;
37
38export { omit };
Note: See TracBrowser for help on using the repository browser.