export default function (fn, limit = 250) {
  let wait = false

  return function (...args) {
    if (wait) {
      return
    }

    wait = true
    fn.apply(this, args)
    setTimeout(() => {
      wait = false
    }, limit)
  }
}

export default function (fn, limit = 250) {
  let wait = false
  let result

  return function (...args) {
    if (wait) {
      return result
    }

    wait = true
    result = fn.apply(this, args)
    setTimeout(() => {
      wait = false
    }, limit)
    return result
  }
}

make throttle return last return value of throttled function (#2246)