Created
June 5, 2019 13:47
-
-
Save wences-dc-uba-ar/0ccc8120e635a40f621562a57a64ffc9 to your computer and use it in GitHub Desktop.
Javascript snippets
This file contains 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
/** | |
* indented prettyPrint caller function | |
*/ | |
function fcallerName() { | |
var err = new Error(); | |
var stack = err.stack.split("\n"); | |
var lft = " ".substr(0, stack.length-3); | |
return [ | |
"%c" + lft + "FUNCTION " + fcallerName.caller.caller.name + "()", | |
"background: #222; color: #bada55;", | |
stack.reverse().slice(0,-3) | |
]; | |
} | |
function log() { | |
var args = fcallerName(), len = arguments.length; | |
while ( len-- ) args[ len + 3 ] = arguments[ len ]; | |
// if(args[0].includes("someFunctionName")) { | |
console.log.apply(console, args); // eslint-disable-line no-console | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment