choke

0.1.2 • Public • Published

choke

Function call throttling with hook for cancelling

browser support

Example

var choke = require("choke")
var EventSource = require("eventsource-reconnect")
var setInterval = require("timers").setInterval
 
var source = new EventSource("http://localhost:1234/events")
var reconnect = choke(source.reconnect, 15000)
 
source.onopen = reconnect.cancel    // kill any outstanding reconnect attempts
 
setInterval(function (){
    if (source.readyState === source.CLOSED) {
        source.onclose = reconnect.listener // throttle reconnects to 15 secs
    }
}, 1000)

Installation

npm install choke

Contributors

  • Matt-Esch

MIT Licenced

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    1
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i choke

Weekly Downloads

0

Version

0.1.2

License

none

Last publish

Collaborators

  • mattesch