Strip comments from code. Removes line comments, block comments, the first comment only, or all comments. Optionally leave protected comments unharmed.
Install with npm
$ npm i strip-comments --savevar strip = require('strip-comments');
console.log(strip('Hey! // foo'));
//=> 'Hey !';Strip comments from the given string.
Params
string{String}options{Object}: Passsafe: trueto keep comments with!returns{String}
Example
//example.strip
console.log(strip("foo // this is a comment\n/* me too *\/"));
//=> 'foo'Strip block comments from the given string.
Params
string{String}options{Object}: Passsafe: trueto keep comments with!returns{String}
Example
console.log(strip.block("foo // this is a comment\n/* me too */"));
//=> 'foo // this is a comment\n'Strip line comments from the given string.
Params
string{String}options{Object}: Passsafe: trueto keep comments with!returns{String}
Example
console.log(strip.line("foo /* me too */"));
//=> 'foo'Strip the first comment from the given string.
Params
string{String}options{Object}: Passsafe: trueto keep comments with!returns{String}
Preserve newlines after comments are stripped.
Type: boolean
Default: undefined
Example
strip(commentString, { preserveNewlines: true });- code-context: Parse a string of javascript to determine the context for functions, variables and comments based… more | homepage
- esprima-extract-comments: Extract code comments from string or from a glob of files using esprima. | homepage
- extract-comments: Extract code comments from string or from a glob of files. | homepage
- js-comments: Parse JavaScript code comments and generate API documentation. | homepage
- parse-code-context: Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype… more | homepage
- parse-comments: Parse code comments from JavaScript or any language that uses the same format. | homepage
- snapdragon: snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory. | homepage
Install dev dependencies:
$ npm i -d && npm testPull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb on December 25, 2015.