Last active
October 16, 2023 12:39
-
-
Save qntm/56996c1bd0c342114ea5 to your computer and use it in GitHub Desktop.
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
// TODO: longer method name | |
Function.prototype.extractBlockCommentAsMultilineString = function() { | |
return this.toString().match(/^function \(\)\{\s*\/\*((?:[^*]|\*+[^*\/])*)\*+\/\s*\}$/)[1]; | |
}; | |
var s = function(){/* | |
STRING | |
GOES | |
HERE | |
*/}.extractBlockCommentAsMultilineString(); | |
console.log("\r\n\tSTRING\r\n\tGOES\r\n\tHERE\r\n" === s); // true, possibly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
extractMultilineStringFromFunctionContainingOnlyABlockComment()