incoherence
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

incoherence

npm version Commitizen friendly

Install

npm i -S incoherence

Comparison

Here is an example to show the difference between regular, debounced and throttled invocations: Visual comparison.

API

debounce

function debounce<A extends [], R>(
  func: (...args: A) => R,
  gap?: number = 128,
  options?: Partial<{
    maxGap: number
    immediate: boolean
  }> = {
    maxGap: Infinity,
    immediate: true,
  },
): (this: any, ...args: A) => Promise<R>

throttle

function throttle<A extends [], R>(
  func: (...args: A) => R,
  gap?: number = 128,
): (this: any, ...args: A) => Promise<R>

Examples

import { debounce, throttle } from 'incoherence'

window.onresize = throttle(() => {
  console.log(window.innerWidth, window.innerHeight)
}, 100)

Package Sidebar

Install

npm i incoherence

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

43 kB

Total Files

20

Last publish

Collaborators

  • rickkky