/**
 * 自定义工具入口
 */
import prototypes from "./modules/prototypes"
import timer from "./modules/timer";
export const util = {
  install(Vue) {
    prototypes();
    timer();
  }
}
import * as jsencrypt from './modules/jsencrypt'
export { jsencrypt }

export { timerBind, timerUnBind } from "./modules/timer";
export { icons } from "./modules/icons";

import Base64 from './modules/base64'

import calculateMD5 from './modules/calculateMD5'

export { calculateMD5 }

const base64 = new Base64()

export { base64, Base64 }


/**
 * This is just a simple version of deep copy
 * Has a lot of edge cases bug
 * If you want to use a perfect deep copy, use lodash's _.cloneDeep
 * @param {Object} source
 * @returns {Object}
 */
export function deepClone(source) {
  if (!source && typeof source !== 'object') {
    throw new Error('error arguments', 'deepClone')
  }
  const targetObj = source.constructor === Array ? [] : {}
  Object.keys(source).forEach(keys => {
    if (source[keys] && typeof source[keys] === 'object') {
      targetObj[keys] = deepClone(source[keys])
    } else {
      targetObj[keys] = source[keys]
    }
  })
  return targetObj
}