import _ from 'lodash';

export const checkoutType = (item: any) => {
    const toString = Object.prototype.toString;
    const str = toString.call(item);
    const splitItem = str.split(' ')[1];
    return splitItem.replace(']', '').toLowerCase();
};

// 保留两位小数，并千分位分隔
export function thousandSeparatorFixed(num: number, len: number = 2) {
    if (isNaN(num)) {
        return num;
    }
    let newNum = num.toFixed(len);
    return newNum.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}

export function getStrLeng(str: string) {
    return str.replace(/[\u0391-\uFFE5]/g, 'aa').length;
}
