Skip to content

Instantly share code, notes, and snippets.

View pretty's full-sized avatar

Stefan Pretty pretty

View GitHub Profile
@sunny
sunny / decay.js
Created September 30, 2008 09:05
// Decay class, to call a callback less and less often. For example,
// make an Ajax request and freshen the decay only if the request has changed.
//
// To start the timeouts, call decay_object.start()
// To freshen up the speed of query, call decay_object.reset()
//
// Options:
// - seconds: time between each callback at the start and after a reset() (default 2)
// - decay: multiplier to use after each callback call (default 1.3)
// - max: maximum number of seconds to wait between each call (default 42)