gasp

0.0.2 • Public • Published

Promise based throttling

Usage:

var Q = require("q");
var gasp = require("gasp");
 
//throttle the XHR to a call every 100ms
var gaspingXHR = gasp(function (url) {
    //make request (imagined api)
    return request.makeRequest(url)
}, 100)
 
var newUpdate;
 
//then make the calls
setInterval(function() {
    newUpdate = gaspingXHR("http://foo.com");
}, 1);
 
newUpdate.then(function (response) {
    // do something ...
})
 

Readme

Keywords

none

Package Sidebar

Install

npm i gasp

Weekly Downloads

348

Version

0.0.2

License

none

Last publish

Collaborators

  • francoisfrisch