JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6320498
  • Score
    100M100P100Q226897F

Strip comments from code. Removes both line comments and/or block comments, with options to leave protected comments unharmed.

Package Exports

  • strip-comments

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strip-comments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

strip-comments NPM version

Strip comments from code. Removes both line comments and/or block comments, with options to leave protected comments unharmed.

Install

Install with npm:

npm i strip-comments --save-dev

Run tests

npm test

Usage

var strip = require('strip-comments');
console.log(strip('Hey! // foo'));
//=> 'Hey !';

API

strip

Strip all comments

  • str {String}: file contents or string to strip.
  • opts {Object}: options are passed to .block, and .line
  • returns {String}: String without comments.

Example:

console.log(strip("foo // this is a comment\n/* me too */"));
//=> 'foo'

.block

Strip only block comments, optionally leaving protected comments (e.g. /*!) intact.

  • str {String}: file content or string to strip to
  • opts {Object}: if safe:true, strip only comments that do not start with /*! or /**!
  • returns {String}: String without block comments.

Example:

console.log(strip("foo // this is a comment\n/* me too */"));
//=> 'foo // this is a comment\n'

.line

Strip only line comments

  • str {String}: file content or string to strip to
  • opts {Object}: if safe:true, strip all that not starts with //!
  • returns {String}: String without line comments.

Example:

console.log(strip("foo /* me too */"));
//=> 'foo'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on September 02, 2014.