super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
83 lines (82 loc) • 1.9 kB
TypeScript
/**
* Checks if path is a direct property of object.
*
* @param object - The object to query
* @param key - The key to check
* @returns Whether the property exists
*
* @example
* ```ts
* const object = { 'a': { 'b': 2 } };
*
* has(object, 'a');
* // => true
*
* has(object, 'a.b');
* // => false
* ```
*/
export declare function has<T extends object>(object: T, key: string | number | symbol): boolean;
/**
* Checks if path is a direct or inherited property of object.
*
* @param object - The object to query
* @param key - The key to check
* @returns Whether the property exists
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* }
*
* Foo.prototype.b = 2;
*
* hasIn(new Foo, 'a');
* // => true
*
* hasIn(new Foo, 'b');
* // => true
* ```
*/
export declare function hasIn<T extends object>(object: T, key: string | number | symbol): boolean;
/**
* Checks if path is a direct property of object.
* Uses dot notation for nested properties.
*
* @param object - The object to query
* @param path - The path to check
* @returns Whether the path exists
*
* @example
* ```ts
* const object = { 'a': { 'b': 2 } };
*
* hasPath(object, 'a.b');
* // => true
*
* hasPath(object, ['a', 'b']);
* // => true
* ```
*/
export declare function hasPath<T extends object>(object: T, path: string | Array<string | number | symbol>): boolean;
/**
* Checks if path is a direct or inherited property of object.
* Uses dot notation for nested properties.
*
* @param object - The object to query
* @param path - The path to check
* @returns Whether the path exists
*
* @example
* ```ts
* const object = { 'a': { 'b': 2 } };
*
* hasInPath(object, 'a.b');
* // => true
*
* hasInPath(object, ['a', 'b']);
* // => true
* ```
*/
export declare function hasInPath<T extends object>(object: T, path: string | Array<string | number | symbol>): boolean;