4 ms·
(Not a JS'er) You can pass a comment as a parameter?
by _1 11y ago
(Not a JS'er) You can pass a comment as a parameter?
- marpstar 11y agonot in the language itself, but you can obtain the full text of a function, detect the comment and parse it, and inject it where ever it needs to go.
- STRML 11y agoYep. "Passing a comment" is used by calling .toString() on the function. It fails when using minification for obvious reasons but of course you wouldn't on Node code. It's a clever hack around JS's awful multiline string support. But with ES6 template strings it's not really needed anymore.
- untog 11y agoYou can, but I'm a little confused as to why you would, instead of just passing a string. Fits in with the esoteric nature of the library, though.