/**
 * Created by Heath on 2019/9/27.
 */
var $VaguePhone = function $VaguePhone(phone) {
  return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
};

var $RemoveLastChar = function $RemoveLastChar(val) {
  return val.substring(0, val.length - 1);
};

var $RemoveItem = function $RemoveItem(list, start, end) {
  var newList = [];

  try {
    list.forEach(function (val, index) {
      if (index <= start || index > end) {
        newList.push(val);
      }
    });
  } catch (e) {
    console.error(e);
  }

  return newList;
};

var $GetCalendar = function $GetCalendar(year, month, isZero) {
  var dayObj = {},
      dayList = [],
      preDayList = [],
      lastDayList = [],
      now = new Date(year, month, 0),
      pre = new Date(year, month - 1, 0);
  var dayCount = now.getDate();
  var preDayCount = pre.getDate();
  var preWeek = new Date(Date.parse(year + "/" + month + "/1")).getDay();
  var lastWeek = new Date(Date.parse(year + "/" + month + "/" + dayCount)).getDay();
  console.log(preWeek);
  console.log(lastWeek, dayCount);

  for (var i = preDayCount - preWeek + 1; i < preDayCount + 1; i++) {
    isZero ? i < 10 ? preDayList.push('0' + i) : preDayList.push(i + '') : preDayList.push(i + '');
  }

  if (lastWeek !== 6) {
    for (var _i = 1; _i < 7 - lastWeek; _i++) {
      isZero ? _i < 10 ? lastDayList.push('0' + _i) : lastDayList.push(_i + '') : lastDayList.push(_i + '');
    }
  }

  for (var _i2 = 1; _i2 < dayCount + 1; _i2++) {
    isZero ? _i2 < 10 ? dayList.push('0' + _i2) : dayList.push(_i2 + '') : dayList.push(_i2 + '');
  }

  dayObj.pre = preDayList;
  dayObj.cur = dayList;
  dayObj.last = lastDayList;
  return dayObj;
};

var $ObjectFlashback = function $ObjectFlashback(Object) {
  var temp = {};
  var keys = [];
  var vals = [];

  for (var key in Object) {
    keys.push(key);
    vals.push(Object[key]);
  }

  for (var i = 0; i < keys.length; i++) {
    temp[keys[i]] = vals[keys.length - 1 - i];
  }

  console.log(temp);
  return temp;
}; // const $RemoveLastItem = (list) => {
//   let newList = [];
//   try {
//     list.forEach((val, index) => {
//       if (index < list.length - 1) {
//         newList.push(val);
//       }
//     });
//   } catch (e) {
//     console.error(e);
//   }
//   return newList;
// };


export { $VaguePhone, $RemoveLastChar, $RemoveItem, $GetCalendar, $ObjectFlashback };
/* eslint-enable */