limits.js
Most Web services have certain limitations regarding how many requests your client application can do in specific timeranges. Dealing with these limitations can be tough, especially if the limitations are more complex like for example: "You can do one request in a second but only a maximum of 20 requests in a minute and a maximum of 100 requests in an hour". This is where limits.js comes to help. limits.js makes sure you don't exceed the given limitations. limits.js works with Node.JS and in the Browser.
Sample
limits = ; queue = ; queue; queue; queue; queue;
Installation
Node.JS
npm install limits.js
Browser
There is minified version availible in the build directory.
Usage
var service = ; // You can also specify the number of calls permitted// in an certain timerange like this: service;service;service;service;service;service; // The predefined ranges don't fit to your requirements?// No problem, try this: service; // With the 'push' method you are able to push a function// into the execution stack.// If the call doesn't get aborted by the second conditional function// you will get an object in return containing an 'delay' property, which indicates// with which delay the function will get called and an 'timer' property which// holds the return of the setTimeout function. var myCall = service;
License
Copyright (c) 2014 Simon Kusterer Licensed under the MIT license.