0.3.0 • Published 9 years ago

on-cooldown v0.3.0

Weekly downloads
9
License
MIT
Repository
github
Last release
9 years ago

On Cooldown Build Status

Simple library for creating functions with cooldowns

Example

Basic

var cooldown = require('on-cooldown');

var fn = cooldown(1000, function(name) {
  console.log("Hello there " + name + "!");
});

fn.on('cooldown.calledOnCooldown', function(func, args) {
  console.log("Function could not be called, it is on cooldown, sorry " + args[0]);
});

fn.on('cooldown.start', function() {
  console.log("Cooldown has been started");
});

fn.on('cooldown.end', function() {
  console.log("Cooldown has ended");
});

fn("Karl")
fn("Bryan");

Basic Bot

var cooldown = require('on-cooldown');

robot.respond(/gems$/i, cooldown(300000, function(msg) {
  // This message will only be send when called, once every 5 minutes
  msg.send('Hello world');
});