// 可以在不同的地方共享数据、传参
const _data: { [key: string]: any } = {}
const get = <T>(key: string, defaultValue?: T): T => {
  if (_data[key] === undefined) {
    _data[key] = defaultValue
  }
  return _data[key]
}

// 设值
const set = (key: string, value: any) => {
  _data[key] = value
}

// 弹出值
const pop = (key: string) => {
  const value = _data[key]
  delete _data[key]
  return value as any
}

export default {
  get,
  set,
  pop,
}
