UNPKG

@polgubau/utils

Version:

A collection of utility functions for TypeScript

1 lines 1.17 kB
{"version":3,"sources":["../../../../src/objects/omit/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":";AAmBO,SAAS,KAAuD,KAAQ,MAAuB;AACpG,QAAM,SAAS,EAAE,GAAG,IAAI;AAExB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;","names":[]}