lodash-omitdeep
Version:
lodash omitDeep/omitByDeep object key/value recursively
52 lines (51 loc) • 2.03 kB
text/typescript
import { Dictionary, Many, NumericDictionary, PartialObject, PropertyName, ValueKeyIteratee } from "lodash";
//#region src/omitDeep/omitDeep.d.ts
interface OmitDeep {
<T extends object, K extends PropertyName[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
<T extends object, K extends keyof T>(object: T | null | undefined, ...paths: Many<K>[]): Omit<T, K>;
<T extends object>(object: T | null | undefined, ...paths: Many<PropertyName>[]): PartialObject<T>;
}
/**
* The opposite of `_.pick`; this method creates an object composed of the
* own and inherited enumerable properties of `object` that are not omitted.
*
* @category Function
* @param object The source object.
* @param [paths] The property names to omit, specified
* individually or in arrays.
* @returns Returns the new object.
* @example
*
* const object = { 'a': 1, 'b': 2, 'c': { 'a': 1, 'b': 2 } };
*
* omitDeep(object, ['b', 'a']);
* // => { 'c': {} }
*/
declare const omitDeep: OmitDeep;
//#endregion
//#region src/omitDeepBy/omitDeepBy.d.ts
interface OmitDeepBy {
<T>(object: Dictionary<T> | null | undefined, predicate?: ValueKeyIteratee<T>): Dictionary<T>;
<T>(object: NumericDictionary<T> | null | undefined, predicate?: ValueKeyIteratee<T>): NumericDictionary<T>;
<T extends object>(object: T | null | undefined, predicate: ValueKeyIteratee<T[keyof T]>): PartialObject<T>;
}
/**
* The opposite of `_.pickBy`; this method creates an object composed of the
* own and inherited enumerable properties of `object` that `predicate`
* doesn't return truthy for.
*
* @category Function
* @param object The source object.
* @param [predicate] The function invoked per property.
* @returns Returns the new object.
* @example
*
* const object = { 'a': 1, 'b': null, 'c': { 'a': 1, 'b': null } };
*
* omitByDeep(object, _.isNil);
* // => { 'a': 1, 'c': { 'a': 1 } }
*/
declare const omitDeepBy: OmitDeepBy;
//#endregion
export { omitDeep, omitDeepBy };
//# sourceMappingURL=index.d.mts.map