Created
March 24, 2018 00:06
-
-
Save paustint/8fc1084f41e48ac902cb4da8d8bdcdc5 to your computer and use it in GitHub Desktop.
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
// utils.resource | |
window.utils = ({ | |
SHOW_LOG: true, // Set to false in production | |
log: function() { }, | |
warn: function() { }, | |
error: function() { }, | |
logInit: function () { | |
if(this.SHOW_LOG) { | |
this.log = console.log.bind(console); | |
this.warn = console.warn.bind(console); | |
this.error = console.error.bind(console); | |
} | |
}, | |
}); | |
// Initialize our log based on the log level | |
window.utils.logInit(); | |
// This is also a good place to put polyfills so they load automatically when the utils are imported. | |
// e.x.: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment