export default class Shake {
  queue = new Map()
  timer = 500
  /**
   * 时间: 毫秒
   * @param {number} timer
   */
  constructor(timer) {
    this.timer = timer
  }
  add(key) {
    const has = this.queue.get(key)
    if (has) return false
    this.queue.set(key, true)
    setTimeout(() => {
      this.queue.set(key, false)
    }, this.timer)
    return true
  }
  remove(key) {
    this.queue.set(key, false)
  }
}
