Limit the execution rate of any function
Limit the execution rate of any function.
npm install function-rate-limit
returns a rate limited function which should be called instead of the
function passed to
limitIntervalto limit execution of
functionspecified in ms
function will be called up to
limitCount times during
limitInterval including bursting.
var rateLimit = ;// limit to 2 executions per 1000msvar start = Datevar fn =;for var y = 0; y < 10; y++;
10 ms - 011 ms - 11004 ms - 21012 ms - 32008 ms - 42013 ms - 53010 ms - 63014 ms - 74017 ms - 84017 ms - 9
Prior to version 1.x.x, this module behaved as a throttle module.
function would be invoked only one time per
limitCount/limitInterval with no bursting. If you need this functionality again and do not want bursting, see the
Copyright (c) 2012 Daniel L. VerWeire
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.