UNPKG

doo

Version:

CoffeeScript library for repeat and delay functions

32 lines (25 loc) 837 B
// Generated by CoffeeScript 1.8.0 (function() { var repeat_tags, root, __slice = [].slice; root = typeof exports !== "undefined" && exports !== null ? exports : this; repeat_tags = {}; root.doo = function() { var callback, options, period, sleep_id, tag, _i; options = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++]; period = options[0], tag = options[1]; sleep_id = setInterval(callback, period || 0); if (tag) { return repeat_tags[tag] = sleep_id; } }; root.after = function(period, callback) { return setTimeout(callback, period || 0); }; root.undoo = function(tag) { if (repeat_tags[tag]) { clearInterval(repeat_tags[tag]); return delete repeat_tags[tag]; } }; }).call(this);