{"version":3,"sources":["../../src/utils/throttle.ts"],"sourcesContent":["import { debounce } from './debounce'\n\nimport type { AnyFunc } from './basic'\n\nexport type ThrottleOptions = {\n  /**\n   * time frame for throttle\n   *\n   * @defaultValue 0\n   */\n  wait?: number\n  /**\n   * whether to invoke the function at the start of each period\n   *\n   * @defaultValue true\n   */\n  leading?: boolean\n  /**\n   * whether to invoke the function at the end of each period\n   *\n   * @defaultValue true\n   */\n  trailing?: boolean\n}\n\nexport type ThrottledFn<T extends AnyFunc> = {\n  /**\n   * The throttled function.\n   */\n  (this: ThisParameterType<T>, ...args: Parameters<T>): ReturnType<T> | undefined\n  /**\n   * Cancels the throttled function.\n   *\n   * @deprecated Use `throttled.cancel()` instead.\n   */\n  clear: () => void\n  /**\n   * Cancels the throttled function.\n   */\n  cancel: () => void\n  /**\n   * Invokes the debounced function immediately.\n   */\n  flush: () => ReturnType<T> | undefined\n}\n\n/**\n * Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds.\n *\n * @from lodash/throttle\n */\nexport function throttle<T extends AnyFunc>(fn: T, options: ThrottleOptions = {}): ThrottledFn<T> {\n  const { wait = 0, leading = true, trailing = true } = options\n\n  return debounce(fn, {\n    wait,\n    leading,\n    trailing,\n    maxWait: wait,\n  })\n}\n"],"names":["throttle","fn","options","wait","leading","trailing","debounce","maxWait"],"mappings":";;;;+BAmDgBA;;;eAAAA;;;wBAnDS;AAmDlB,SAASA,SAA4BC,EAAK;QAAEC,UAAAA,iEAA2B,CAAC;IAC7E,oBAAsDA,QAA9CC,MAAAA,kCAAO,sCAAuCD,QAApCE,SAAAA,wCAAU,6CAA0BF,QAApBG,UAAAA,0CAAW;IAE7C,OAAOC,IAAAA,kBAAQ,EAACL,IAAI;QAClBE,MAAAA;QACAC,SAAAA;QACAC,UAAAA;QACAE,SAASJ;IACX;AACF"}