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

extract-comments

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-comments - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

32

index.js

@@ -60,6 +60,8 @@ 'use strict';

while (startIdx !== -1 && endIdx < len) {
var isQuoted = utils.isQuotedString(startIdx, ranges);
if (isQuoted) {
endIdx = end(str, startIdx, len);
if (endIdx === -1) endIdx = len;
endIdx = end(str, startIdx, len);
if (endIdx === -1) break;
var quoted = utils.isQuotedString(startIdx, ranges);
if (quoted) {
startIdx = endIdx;
continue;

@@ -77,5 +79,2 @@ }

endIdx = end(str, startIdx, len);
if (endIdx === -1) break;
var comment = fn(new Block(str, startIdx, endIdx));

@@ -89,2 +88,3 @@ arr.push(comment);

startIdx = start(str, prevIdx);
if (startIdx >= len) break;
}

@@ -140,13 +140,19 @@

while (startIdx !== -1 && endIdx < len) {
if (startIdx >= len || endIdx >= len) {
break;
}
endIdx = end(str, startIdx, len);
if (endIdx === -1) endIdx = len;
var isQuoted = utils.isQuotedString(startIdx, ranges);
if (isQuoted) {
startIdx = start(str, endIdx);
continue;
if (endIdx === -1) {
endIdx = len;
}
var quoted = utils.isQuotedString(startIdx, ranges);
var comment = new Line(str, startIdx, endIdx);
startIdx = start(str, endIdx);
if (quoted) {
startIdx = endIdx + 1;
continue;
}

@@ -153,0 +159,0 @@ if (prev && combine && isStacked(comment, prev, opts)) {

@@ -5,5 +5,6 @@ 'use strict';

var bom = require('strip-bom-string');
var quotedStringRegex = require('quoted-string-regex');
var quotesRe = require('quoted-string-regex');
var repeat = require('repeat-string');
var range = require('to-regex-range');
var cache = {};

@@ -56,22 +57,33 @@ /**

utils.getRanges = function (str) {
var re = quotedStringRegex();
var m, ranges = [];
if (cache[str]) return cache[str];
var re = quotesRe();
var ranges = [];
var m;
while (m = re.exec(str)) {
var len = m[0].length;
ranges.push(new RegExp(range(m.index, m.index + len)));
var filler = repeat(' ', len);
str = str.replace(m[0], filler);
var regex = utils.toRange(m.index, m.index + m[0].length);
ranges.push({
regex: regex,
index: m.index,
match: m,
});
}
cache[str] = ranges;
return ranges;
};
utils.toRange = function (a, b) {
return new RegExp(range(a, b));
};
utils.isQuotedString = function (num, ranges) {
var len = ranges.length, i = -1;
if (len === 0) return false;
var m;
while (++i < len) {
var re = ranges[i];
var range = ranges[i];
var re = range.regex;
if (re.test(num.toString())) {
return true;
return range;
}

@@ -78,0 +90,0 @@ }

{
"name": "extract-comments",
"description": "Extract code comments from string or from a glob of files.",
"version": "0.8.3",
"version": "0.8.4",
"homepage": "https://github.com/jonschlinkert/extract-comments",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

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