1. import { isObject } from './type';
    2. export function objectToArray<T = string>(val: {[key: string]: any; }, onlyValue: boolean = false) {
    3. if (!isObject(val)) return val;
    4. if (onlyValue) {
    5. return Object.values(val);
    6. }
    7. const keys = Object.keys(val);
    8. return keys.map((key) => ({
    9. key,
    10. value: val[key] as T,
    11. }));
    12. }
    13. export const firstStrToUpper = (str: string) => {
    14. if (typeof str !=== 'string') {
    15. return str;
    16. }
    17. return str.replace(/a-z/, (match) => match.toUpperCase());
    18. }