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

cdocparser

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdocparser - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

14

index.js

@@ -0,1 +1,5 @@

'use strict';
var stripIndent = require('strip-indent');
/**

@@ -5,10 +9,8 @@ * Extract all C-Style comments from the input code

var CommentExtractor = (function () {
var docCommentRegEx = /\/\*\*((?:[^*]|[\r\n]|(?:\*+(?:[^*/]|[\r\n])))*)\*\//gm;
var docCommentRegEx = /^[ \t]*\/\*\*((?:[^*]|[\r\n]|(?:\*+(?:[^*/]|[\r\n])))*)\*\//gm;
var cleanComment = function (comment) {
// Split all comments at \r or \n
var commentLines = comment.replace(/^\s+|\s+$/g,'').match(/[^\r\n]+/g);
return commentLines.map(function(line){
return line.replace(/^\s*\*\s*/, '');
});
var removeFirstLine = comment.replace(/^.*?[\r\n]+|[\r\n].*?$/g, '');
var removeLeadingStar = removeFirstLine.replace(/^[ \t]*\*/gm, '');
return stripIndent(removeLeadingStar).split(/\n/);
};

@@ -15,0 +17,0 @@

{
"name": "cdocparser",
"version": "0.0.11",
"version": "0.0.12",
"description": "Extract C style comments and extract context from source",

@@ -23,3 +23,6 @@ "main": "index.js",

"assert": "^1.1.1"
},
"dependencies": {
"strip-indent": "^0.1.3"
}
}

@@ -28,8 +28,8 @@ var assert = require("assert");

it('should extract more than one comment', function(){
var comments = extractor.extract('/**\n* Comment\n */ /**\n* Comment\n */ /**\n* Comment\n */');
var comments = extractor.extract('/**\n * Comment\n */\n/**\n * Comment\n */\n/**\n* Comment\n */');
assert.equal(comments.length, 3);
});
it('should ignore block comments like /* comment */', function(){
var comments = extractor.extract('/**\n* Comment\n */ /*\n* Comment\n */ /**\n* Comment\n */');
it ('should ignore block comments like /* comment */', function(){
var comments = extractor.extract('/**\n* Comment\n */\n/*\n* Comment\n */\n/**\n* Comment\n */');
assert.equal(comments.length, 2);

@@ -43,2 +43,14 @@ });

});
it('should ignore `**` in single line comments', function(){
var comments = extractor.extract('//** \n\n\n */');
assert.equal(comments.length, 0);
});
it('should normalize the indentation', function(){
var comments = extractor.extract('/**\n * @example\n * @include chain(bright, ".test") {\n * color: #fff;\n * }\n */');
assert.deepEqual(comments[0].lines, ['@example', ' @include chain(bright, ".test") {', ' color: #fff;', ' }' ]);
});
});

@@ -45,0 +57,0 @@

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