import { isEmpty } from './isEmpty';

/**
 * Get keys from an object
 * @example
 * ```ts
 * const myObj = { a: 1, b: 2, c: 3 };
 * console.log(keys(myObj));
 * // Output: ['a', 'b', 'c']
 * ```
 * @param obj object with string keys
 * @returns the keys of the object passed as parameter
 */
export function keys<T>(obj?: T): string[] {
  if (isEmpty(obj)) {
    return [];
  }
  if (typeof obj !== 'object' || obj === null) {
    throw new TypeError('Expected an object');
  }

  return Object.keys(obj);
}
