Skip to content

Instantly share code, notes, and snippets.

@you21979
Last active December 15, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save you21979/5290136 to your computer and use it in GitHub Desktop.
Save you21979/5290136 to your computer and use it in GitHub Desktop.
指定した時間で回数制限を行う関数。
var createLimitter = function(max, reset_sec){
var reset_time = process.uptime() + reset_sec;
var count = 0;
return function(){
if(process.uptime() >= reset_time){
reset_time = process.uptime() + reset_sec;
count = 0;
}
if(count >= max){
return false;
}
count++;
return true;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment