nanobounce

1.1.0 • Public • Published

nanobounce stability

npm version build status downloads js-standard-style

Smol debounce package.

Usage

var Nanobounce = require('nanobounce')
var html = require('bel')
 
var nanobounce = Nanobounce()
html`
  <input onkeydown=${onkeydown}>click me</button>
`
function onkeydown (e) {
  var value = e.target.value
  nanobounce(function () {
    console.log('called at the start of a new frame', value)
  })
}

Why?

Because most debounce functions don't work well when doing DOM diffing. This package is specifically made to work well with DOM diffing.

API

nanobounce = Nanobounce([timeout])

Create a new instance. Timeout defaults to 256ms.

nanobounce(callback)

Debounce a callback for the duration of the timeout. The last callback wins if called multiple times in a row.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i nanobounce

Weekly Downloads

61

Version

1.1.0

License

none

Unpacked Size

4.05 kB

Total Files

5

Last publish

Collaborators

  • mreinstein
  • benlyn
  • s3ththompson
  • yoshuawuyts
  • bret
  • lrlna
  • yerkopalma
  • juliangruber
  • timwis
  • ahdinosaur
  • toddself
  • sethvincent
  • maxogden
  • shama
  • freeman-lab
  • feross
  • emilbayes
  • colingourlay
  • jameskyburz
  • almost
  • slaskis
  • ungoldman
  • graforlock
  • tornqvist
  • amongiants
  • goto-bus-stop
  • mafintosh