UNPKG

chocolate

Version:

A full stack Node.js web framework built using Coffeescript

168 lines (159 loc) 4.55 kB
// Generated by CoffeeScript 1.12.6 (function() { var Debugate, _module, slice = [].slice; Debugate = (function() { function Debugate() {} Debugate.log = function() { var what, x; what = 1 <= arguments.length ? slice.call(arguments, 0) : []; return console.log('DEBUG:', ((function() { var i, len, results; results = []; for (i = 0, len = what.length; i < len; i++) { x = what[i]; results.push("" + x); } return results; })()).join(' ')); }; Debugate.profile = (function() { var count, fn, fn_now, fns, pulse, start, time, total; count = {}; start = {}; time = {}; pulse = {}; total = { count: 0, time: 0 }; if (typeof window === "undefined" || window === null) { try { fn = require('microtime'); fn_now = function() { return fn.now(); }; } catch (error) {} } if (fn_now == null) { fn_now = function() { return Date.now() * 1000; }; } return fns = { count: function(x) { if (count[x] == null) { count[x] = 0; } count[x] += 1; return total.count += 1; }, start: function(x, reset) { if (reset) { fns.reset(x); } fns.count(x); if (start[x] == null) { start[x] = []; } start[x].push(fn_now()); }, end: function(x, xx) { var lapse, now, ref, started; now = fn_now(); started = (ref = start[x].pop()) != null ? ref : now; if (time[x] == null) { time[x] = 0; } time[x] += lapse = now - started; total.time += lapse; if (start[x].length === 0) { start[x] = null; } if (xx != null) { if (start[xx] == null) { start[xx] = []; } start[xx].push(now); fns.count(xx); } }, toggle: function(x, level) { if (!((start[x] != null) && ((level == null) || (start[x][level] == null)))) { return fns.start(x); } else { return fns.end(x); } }, pulse: function(x, level, reset) { var xx; if ((level != null) && (level === true || level === false)) { reset = level; level = null; } if (pulse[x] == null) { pulse[x] = 0; } if (reset === true) { pulse[x] = 0; } if (!((start[xx = x + pulse[x]] != null) && ((level == null) || (start[xx][level] == null)))) { return fns.start(xx); } else { if (reset !== false) { return fns.end(xx, x + ++pulse[x]); } else { return fns.end(xx); } } }, reset: function(x) { var k, ref, ref1; if (x != null) { total.count -= (ref = count[x]) != null ? ref : 0; total.time -= (ref1 = time[x]) != null ? ref1 : 0; count[x] = time[x] = pulse[x] = 0; return start[x] = null; } else { for (k in count) { count[k] = time[k] = pulse[x] = 0; start[k] = null; } return total.count = total.time = 0; } }, wait: function(y) { var i, ref, results; results = []; for (i = 0, ref = y; 0 <= ref ? i < ref : i > ref; 0 <= ref ? i++ : i--) { } return results; }, spent: function(x) { var data, k, ref, ref1; if (x != null) { return { time: (ref = time[x]) != null ? ref : 0, count: (ref1 = count[x]) != null ? ref1 : 0, total: total }; } else { data = {}; for (k in count) { data[k] = { time: time[k], count: count[k] }; } return { data: data, total: total }; } } }; })(); return Debugate; })(); _module = typeof window !== "undefined" && window !== null ? window : module; _module[_module.exports != null ? "exports" : "Debugate"] = Debugate; }).call(this);