block-failed
0.0.1 • Public • Published node-block-failed
// blocker will block for BLOCKED_DURATION_MS if ATTEMPT_COUNT failed attempts are made within ATTEMPT_DURATION_MS
blocker = blockFailed(BLOCKED_DURATION_MS, ATTEMPT_DURATION_MS, ATTEMPT_COUNT)
// blocker is now (key, on_attempt, on_block) => void
// on_attempt is on_failure => ...
// on_block is blockDurationMS => ...
...
block(ip_address, on_failure =>
{
try
{
...
}
catch (e)
{
if (!on_failure())
{
console.log('operation failed. please try again');
}
}
},
blockDurationMS =>
{
console.log('operation blocked. please try again in', blockDurationMS, 'ms');
});
Readme
Keywords
nonePackage Sidebar
Install
Weekly Downloads