Socket
Socket
Sign inDemoInstall

strip-comments

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-comments - npm Package Compare versions

Comparing version 0.1.4 to 0.1.6

test/expected/banner-protected.js

2

bower.json
{
"name": "strip-comments",
"version": "0.1.4",
"version": "0.1.6",
"main": [

@@ -5,0 +5,0 @@ "index.js"

@@ -29,4 +29,8 @@ /**

strip.banner = function(str) {
strip.banner = function(str, opts) {
opts = opts || {};
var re = new RegExp('^' + reBlock + '\\s+', 'g');
if(opts.safe) {
re = new RegExp('^[^\\/\*\*?\!]' + reBlock + '\\s+', 'g');
}
return str ? str.replace(re, '') : '';

@@ -33,0 +37,0 @@ };

{
"name": "strip-comments",
"description": "Strip comments from code. Remove both line comments and block comments.",
"version": "0.1.4",
"version": "0.1.6",
"main": "index.js",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/jonschlinkert/strip-comments",

@@ -81,3 +81,3 @@ # strip-comments [![NPM version](https://badge.fury.io/js/strip-comments.png)](http://badge.fury.io/js/strip-comments)

```
Not
Not line comments

@@ -88,2 +88,59 @@ ```js

### block (safe)
```js
strip.safeBlock( str );
```
Removes
```js
/**
* this
* comment
*/
```
but not comments with `/*!` or `/**!`
```js
/*!
* this
* comment
*/
```
or line comments
```js
// This comment
```
### banners
```js
strip.banner( str );
```
Removes the top comment in files
```js
/**
* this
* comment
*/
var foo = function(/* and these */) {}
```
### banners (safe)
```js
strip.banner( str, {safe: true} );
```
Removes the top comment in files, except for those with `/*!` or `/**!`:
```js
/**!
* this comment won't
* be removed
*/
```
## Tests

@@ -90,0 +147,0 @@

@@ -14,3 +14,3 @@ const expect = require('chai').expect;

describe('banners only:', function () {
describe('when `strip.banner` is used:', function () {
it('should strip banners only.', function () {

@@ -24,2 +24,12 @@ var fixture = file.readFileSync('test/fixtures/banner-strip.js');

describe('when `strip.banner` is used, and options.safe is specified:', function () {
it('should strip banners, except for protected banners.', function () {
var fixture = file.readFileSync('test/fixtures/banner-keep.js');
var actual = strip.banner(fixture, {safe: true});
var expected = file.readFileSync('test/expected/banner-protected.js');
expect(actual).to.eql(expected);
});
});
describe('all except banners:', function () {

@@ -26,0 +36,0 @@ it('should strip all block comments except banner.', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc