node-cooldown

0.0.4 • Public • Published

Installation

npm i node-cooldown

usage

const Cooldown = require('node-cooldown')

var cooldown = new Cooldown(500, true/*prevent memory leak. default true */) // 500 milliseconds of cooldown
// new Cooldown('assdasd') // throws

console.log(cooldown.check('some ID. note it should be unique and dosend change; type: any'))
// returns { pass: true, restTime: null } or { pass: false, restTime: 32489 }

setTimeout(() => {
    // check after ~300 mills
    console.log(cooldown.check('some ID. note it should be unique and dosend change; type: any'))    //{ pass: false, restTime: 194 }

    setTimeout(() => {
        //check again after ~500 mills
        console.log(cooldown.check('some ID. note it should be unique and dosend change; type: any'))//{ pass: true, restTime: null }

    }, 500);
}, 300);

note

I made this tool to use it in a discord bot. So it should work there

Readme

Keywords

Package Sidebar

Install

npm i node-cooldown

Weekly Downloads

5

Version

0.0.4

License

MIT

Unpacked Size

4.15 kB

Total Files

3

Last publish

Collaborators

  • 1euro7cent