Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decomment

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decomment - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

test/entrySpec.js

25

index.js

@@ -54,5 +54,3 @@ 'use strict';

}
if (regExIdx < 0) {
regExIdx = idx; // possible regular expression start;
}
regExIdx = idx; // possible regular expression start;
}

@@ -98,14 +96,13 @@

function isInsideRegEx() {
if (regExIdx < 0) {
return false;
if (regExIdx >= 0) {
var lb = text.indexOf(os.EOL, regExIdx + 1);
var line = text.substr(regExIdx, lb < 0 ? (len - regExIdx) : (lb - regExIdx));
var startIdx = idx - regExIdx + 1; // local index that follows the symbol;
var l = line.length, nextIdx = startIdx;
do {
if (line[nextIdx] === '/' && (nextIdx === l - 1 || line[nextIdx + 1] !== '/') && (nextIdx === startIdx || line[nextIdx - 1] !== '\\')) {
return true; // regEx closure found;
}
} while (++nextIdx < l);
}
var lb = text.indexOf(os.EOL, regExIdx + 1);
var line = text.substr(regExIdx, lb < 0 ? (len - regExIdx) : (lb - regExIdx));
var startIdx = idx - regExIdx + 1; // local index that follows the symbol;
var l = line.length, nextIdx = startIdx;
do {
if (line[nextIdx] === '/' && (nextIdx === l - 1 || line[nextIdx] !== '/') && (nextIdx === startIdx || line[nextIdx - 1] !== '\\')) {
return true; // regEx closure found;
}
} while (++nextIdx < l);
return false;

@@ -112,0 +109,0 @@ }

{
"name": "decomment",
"version": "0.0.4",
"version": "0.0.5",
"description": "Removes comments from JSON or JavaScript.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -7,2 +7,3 @@ decomment

[![Build Status](https://travis-ci.org/vitaly-t/decomment.svg?branch=master)](https://travis-ci.org/vitaly-t/decomment)
[![Coverage Status](https://coveralls.io/repos/vitaly-t/decomment/badge.svg?branch=master)](https://coveralls.io/r/vitaly-t/decomment?branch=master)

@@ -42,1 +43,6 @@ ### Installing

* Compliant with ECMAScript 6
In terms of the performance, this library is as fast as it gets,
in part because it makes no use of regular expressions.
For example, it churns through the [source of AngularJS 1.5 Core](https://code.angularjs.org/1.5.0-rc.0/angular.js) (1.1MB of JavaScript) in under 40ms.

@@ -11,2 +11,14 @@ 'use strict';

describe("single-line gaps", function () {
it("must be removed", function () {
expect(decomment("//one" + LB + "//two" + LB + "//three")).toBe("");
});
});
describe("multi-line gaps", function () {
it("must be removed", function () {
expect(decomment("/*one*/" + LB + "/*two*/" + LB + "/*three*/")).toBe("");
});
});
});

@@ -114,2 +114,8 @@ 'use strict';

});
describe("unfinished comment", function () {
it("must assume the comment till the end", function () {
expect(decomment("/*")).toBe(""); // Cutting invalid JavaScript;
});
});
});

@@ -14,2 +14,3 @@ 'use strict';

expect(decomment("/'/")).toBe("/'/");
expect(decomment("/'/" + LB)).toBe("/'/" + LB);
expect(decomment("/\'/")).toBe("/'/");

@@ -22,2 +23,3 @@ });

expect(decomment('/"/')).toBe('/"/');
expect(decomment('/"/' + LB)).toBe('/"/' + LB);
expect(decomment('/\"/')).toBe('/"/');

@@ -30,2 +32,3 @@ });

expect(decomment('/`/')).toBe('/`/');
expect(decomment('/`/' + LB)).toBe('/`/' + LB);
expect(decomment('/\`/')).toBe('/`/');

@@ -56,2 +59,8 @@ });

describe("unfinished regex", function () {
it("must remain unchanged", function () {
expect(decomment("/'")).toBe("/'");
expect(decomment("/'//")).toBe("/'"); // Cutting invalid JavaScript;
});
});
});
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