Created
April 24, 2017 15:08
-
-
Save shellscape/fdcd98aa743b683eb4539336b06200c9 to your computer and use it in GitHub Desktop.
signal event debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (root) { | |
'use strict'; | |
var scope = 'bananas', // whatever your company global variable is | |
enabled = /(\?|&)debug=true/.test(document.location.search); | |
if (!root[scope) { | |
root[scope] = { | |
signal: {} | |
}; | |
}; | |
function debug () { | |
if (!enabled) { | |
return; | |
} | |
var args = Array.prototype.slice.call(arguments); | |
console.info.apply(console, ['Signal: debug →'].concat(args)); | |
} | |
debug.isEnabled = function () { | |
return enabled; | |
}; | |
debug.enable = function () { | |
enabled = true; | |
}; | |
debug.disable = function () { | |
enabled = false; | |
}; | |
root[scope].signal.debug = debug; | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment