JSPM

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

Strip comments from code. Removes line comments, block comments, the first comment only, or all comments. Optionally 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 Build Status

Strip comments from code. Removes line comments, block comments, the first comment only, or all comments. Optionally leave protected comments unharmed.

Install

Install with npm

$ npm i strip-comments --save

Usage

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

API

strip

Strip comments from the given string.

Params

  • string {String}
  • options {Object}: Pass safe: true to keep comments with !
  • returns {String}

Example

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

block

Strip block comments from the given string.

Params

  • string {String}
  • options {Object}: Pass safe: true to keep comments with !
  • returns {String}

Example

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

line

Strip line comments from the given string.

Params

  • string {String}
  • options {Object}: Pass safe: true to keep comments with !
  • returns {String}

Example

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

first

Strip the first comment from the given string.

Params

  • string {String}
  • options {Object}: Pass safe: true to keep comments with !
  • returns {String}

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on November 04, 2015.