https://github.com/moagrius/stripcomments
https://github.com/moagrius/stripcomments
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/moagrius/stripcomments
- Owner: moagrius
- License: mit
- Created: 2013-02-16T07:00:50.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-03-08T20:28:05.000Z (over 10 years ago)
- Last Synced: 2025-03-27T01:21:46.599Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 19
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple JS parser to strip comments
// this is a comment
/* this
* is a multiline
* comment
*/
Usage is simple - create an instance and call .strip(string) to get back the de-commented string...
var cs = new CommentStripper();
console.log( cs.strip(someString) );
It's *intended* to be 100% effective - catching any valid comment, including:
var a = 10; // comment
var a = "http://www.github.com"; // more comments
var a = function(arg /*, ...rest */)
etc.
I've tested it a bit against use-cases I could think of, and tried it against a few common libraries (e.g., the dev version of jQuery), and it seems fine, but I'd be interested to hear if anyone breaks it.