super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
124 lines (123 loc) • 2.77 kB
TypeScript
/**
* Creates an array of the own enumerable property names of object.
*
* @param object - The object to query
* @returns The array of property names
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* keys('hi');
* // => ['0', '1']
* ```
*/
export declare function keys<T extends object>(object: T): Array<string & keyof T>;
/**
* Creates an array of the own and inherited enumerable property names of object.
*
* @param object - The object to query
* @returns The array of property names
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* keysIn(new Foo);
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
* ```
*/
export declare function keysIn<T extends object>(object: T): string[];
/**
* Creates an array of the own enumerable string keyed property values of object.
*
* @param object - The object to query
* @returns The array of property values
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* values(new Foo);
* // => [1, 2] (iteration order is not guaranteed)
*
* values('hi');
* // => ['h', 'i']
* ```
*/
export declare function values<T extends object>(object: T): Array<T[keyof T]>;
/**
* Creates an array of the own and inherited enumerable string keyed property
* values of object.
*
* @param object - The object to query
* @returns The array of property values
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* valuesIn(new Foo);
* // => [1, 2, 3] (iteration order is not guaranteed)
* ```
*/
export declare function valuesIn<T extends object>(object: T): any[];
/**
* Creates an array of own enumerable string keyed-value pairs for object.
*
* @param object - The object to query
* @returns The key-value pairs
*
* @example
* ```ts
* toPairs({ 'a': 1, 'b': 2 });
* // => [['a', 1], ['b', 2]]
* ```
*/
export declare function toPairs<T extends object>(object: T): Array<[string, any]>;
/**
* Creates an array of own and inherited enumerable string keyed-value pairs
* for object.
*
* @param object - The object to query
* @returns The key-value pairs
*
* @example
* ```ts
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* toPairsIn(new Foo);
* // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
* ```
*/
export declare function toPairsIn<T extends object>(object: T): Array<[string, any]>;
export declare const entries: typeof toPairs;
export declare const entriesIn: typeof toPairsIn;