{"version":3,"file":"omitDeep.cjs","sources":["../../../src/omitDeep/omitDeep.ts"],"sourcesContent":["import type { Many, PartialObject, PropertyName } from 'lodash';\n\nimport lodash from 'lodash';\n\nexport const needOmit = (value: any) =>\n  !lodash.isNil(value) && (lodash.isPlainObject(value) || Array.isArray(value));\n\ninterface OmitDeep {\n  <T extends object, K extends PropertyName[]>(\n    object: T | null | undefined,\n    ...paths: K\n  ): Pick<T, Exclude<keyof T, K[number]>>;\n  <T extends object, K extends keyof T>(\n    object: T | null | undefined,\n    ...paths: Many<K>[]\n  ): Omit<T, K>;\n  <T extends object>(\n    object: T | null | undefined,\n    ...paths: Many<PropertyName>[]\n  ): PartialObject<T>;\n}\n\n/**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable properties of `object` that are not omitted.\n *\n * @category Function\n * @param object The source object.\n * @param [paths] The property names to omit, specified\n *  individually or in arrays.\n * @returns Returns the new object.\n * @example\n *\n * const object = { 'a': 1, 'b': 2, 'c': { 'a': 1, 'b': 2 } };\n *\n * omitDeep(object, ['b', 'a']);\n * // => { 'c': {} }\n */\nexport const omitDeep: OmitDeep = (object: any, ...paths: any) => {\n  function omitDeepOnOwnProps(object: any) {\n    if (!Array.isArray(object) && !lodash.isPlainObject(object)) {\n      return object;\n    }\n\n    if (Array.isArray(object)) {\n      return object.map((element) => (needOmit(element) ? omitDeep(element, ...paths) : element));\n    }\n\n    const temp = {};\n\n    for (const [key, value] of Object.entries<{\n      [x: string]: object | PropertyName;\n    }>(object)) {\n      (temp as any)[key] = needOmit(value) ? omitDeep(value, ...paths) : value;\n    }\n    return lodash.omit(temp, ...paths);\n  }\n\n  return omitDeepOnOwnProps(object);\n};\n"],"names":["needOmit","value","lodash","omitDeep","object","paths","omitDeepOnOwnProps","element","temp","key"],"mappings":"0GAIaA,EAAYC,GACvB,CAACC,EAAO,MAAMD,CAAK,IAAMC,EAAO,cAAcD,CAAK,GAAK,MAAM,QAAQA,CAAK,GAiChEE,EAAqB,CAACC,KAAgBC,IAAe,CAChE,SAASC,EAAmBF,EAAa,CACnC,GAAA,CAAC,MAAM,QAAQA,CAAM,GAAK,CAACF,EAAO,cAAcE,CAAM,EACjDA,OAAAA,EAGL,GAAA,MAAM,QAAQA,CAAM,EACtB,OAAOA,EAAO,IAAKG,GAAaP,EAASO,CAAO,EAAIJ,EAASI,EAAS,GAAGF,CAAK,EAAIE,CAAQ,EAG5F,MAAMC,EAAO,CAAC,EAEd,SAAW,CAACC,EAAKR,CAAK,IAAK,OAAO,QAE/BG,CAAM,EACNI,EAAaC,CAAG,EAAIT,EAASC,CAAK,EAAIE,EAASF,EAAO,GAAGI,CAAK,EAAIJ,EAErE,OAAOC,EAAO,KAAKM,EAAM,GAAGH,CAAK,CAAA,CAGnC,OAAOC,EAAmBF,CAAM,CAClC"}