strip-comments
Advanced tools
Comparing version 0.4.2 to 0.4.3
15
index.js
@@ -8,2 +8,8 @@ 'use strict'; | ||
* | ||
* ```js | ||
* //example.strip | ||
* console.log(strip("foo // this is a comment\n/* me too *\/")); | ||
* //=> 'foo' | ||
* ``` | ||
* @name strip | ||
* @param {String} `string` | ||
@@ -33,2 +39,3 @@ * @param {Object} `options` Pass `safe: true` to keep comments with `!` | ||
* | ||
* @name .block | ||
* @param {String} `string` | ||
@@ -47,2 +54,3 @@ * @param {Object} `options` Pass `safe: true` to keep comments with `!` | ||
* | ||
* @name .line | ||
* @param {String} `string` | ||
@@ -61,2 +69,3 @@ * @param {Object} `options` Pass `safe: true` to keep comments with `!` | ||
* | ||
* @name .first | ||
* @param {String} `string` | ||
@@ -100,3 +109,7 @@ * @param {Object} `options` Pass `safe: true` to keep comments with `!` | ||
} | ||
return str.replace(comment.raw, ''); | ||
var nl = ''; | ||
if (opts && opts.preserveNewlines) { | ||
nl = comment.raw.replace(/[^\r\n]/g, ''); | ||
} | ||
return str.replace(comment.raw, nl); | ||
} | ||
@@ -103,0 +116,0 @@ |
{ | ||
"name": "strip-comments", | ||
"description": "Strip comments from code. Removes line comments, block comments, the first comment only, or all comments. Optionally leave protected comments unharmed.", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"homepage": "https://github.com/jonschlinkert/strip-comments", | ||
@@ -22,3 +22,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"extract-comments": "^0.8.5" | ||
"extract-comments": "^0.8.7" | ||
}, | ||
@@ -46,12 +46,15 @@ "devDependencies": { | ||
"list": [ | ||
"snapdragon", | ||
"code-context", | ||
"esprima-extract-comments", | ||
"extract-comments", | ||
"js-comments", | ||
"parse-code-context", | ||
"parse-comments", | ||
"code-context", | ||
"parse-code-context" | ||
"snapdragon" | ||
] | ||
} | ||
}, | ||
"plugins": [ | ||
"gulp-format-md" | ||
] | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# strip-comments [![NPM version](https://badge.fury.io/js/strip-comments.svg)](http://badge.fury.io/js/strip-comments) [![Build Status](https://travis-ci.org/jonschlinkert/strip-comments.svg)](https://travis-ci.org/jonschlinkert/strip-comments) | ||
# strip-comments [![NPM version](https://img.shields.io/npm/v/strip-comments.svg)](https://www.npmjs.com/package/strip-comments) [![Build Status](https://img.shields.io/travis/jonschlinkert/strip-comments.svg)](https://travis-ci.org/jonschlinkert/strip-comments) | ||
@@ -23,3 +23,3 @@ > Strip comments from code. Removes line comments, block comments, the first comment only, or all comments. Optionally leave protected comments unharmed. | ||
### [strip](index.js#L14) | ||
### [strip](index.js#L20) | ||
@@ -37,7 +37,8 @@ Strip comments from the given `string`. | ||
```js | ||
console.log(strip("foo // this is a comment\n/* me too */")); | ||
//example.strip | ||
console.log(strip("foo // this is a comment\n/* me too *\/")); | ||
//=> 'foo' | ||
``` | ||
### [block](index.js#L38) | ||
### [.block](index.js#L45) | ||
@@ -59,3 +60,3 @@ Strip block comments from the given `string`. | ||
### [line](index.js#L51) | ||
### [.line](index.js#L59) | ||
@@ -77,3 +78,3 @@ Strip line comments from the given `string`. | ||
### [first](index.js#L64) | ||
### [.first](index.js#L73) | ||
@@ -88,2 +89,18 @@ Strip the first comment from the given `string`. | ||
## Options | ||
### options.preserveNewlines | ||
Preserve newlines after comments are stripped. | ||
**Type**: `boolean` | ||
**Default**: `undefined` | ||
**Example** | ||
```js | ||
strip(commentString, { preserveNewlines: true }); | ||
``` | ||
## Related projects | ||
@@ -109,3 +126,3 @@ | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](/new). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/strip-comments/issues/new). | ||
@@ -116,8 +133,8 @@ ## Author | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright © 2015 Jon Schlinkert | ||
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert) | ||
Released under the MIT license. | ||
@@ -127,2 +144,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 04, 2015._ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on December 25, 2015._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9098
107
137
Updatedextract-comments@^0.8.7