15 lines
385 B
TypeScript
Executable File
15 lines
385 B
TypeScript
Executable File
/**
|
|
* Return an array of keys from an object.
|
|
*
|
|
* @param object - The object from which to extract the keys.
|
|
* @returns An array of keys from the object.
|
|
*
|
|
* @example
|
|
* const obj = { a: 1, b: 2, c: 3 };
|
|
* const result = keys(obj);
|
|
* // result: ['a', 'b', 'c']
|
|
*/
|
|
export function keys<T extends object>(object: T): (keyof T)[] {
|
|
return Object.keys(object) as (keyof T)[];
|
|
}
|