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.3.0-pre3 to 0.3.0-pre4

34

index.js

@@ -16,2 +16,24 @@ 'use strict';

/**
* Generate a function that will index a buffer of text
* and return a line for a specify char index
*
* @param {String} buffer buffer that is indexed
* @return {Function} Function that translates an char index to line number
*/
function index(buffer) {
var indexData = {0: 0};
for (var i = 0, length = buffer.length, line = 1; i < length; i++) {
if (buffer[i] === '\n') {
indexData[i + 1] = ++line;
}
}
return function (offset) {
for (var i = offset; i >= 0 && buffer[i] != '\n'; i--);
return indexData[i + 1];
};
}
var cleanBlockComment = function (comment) {

@@ -37,2 +59,3 @@ var removeFirstLine = comment.replace(/^.*?[\r\n]+|[\r\n].*?$/g, '');

lines = stripIndent(removedCommentChars).split('\n');
return {

@@ -57,2 +80,4 @@ lines : lines,

var lineNumberFor = index(code);
while ( (match = docCommentRegEx.exec(code)) ) {

@@ -73,6 +98,13 @@ var commentType = 'normal';

}
var matchIndex = match.index + match[0].length;
var lineNumberWithOffsetFor = function(offset){
return lineNumberFor(matchIndex + offset);
};
comments.push({
lines: lines,
type: commentType,
context: this.parseContext(code.substr(match.index + match[0].length))
context: this.parseContext(code.substr(matchIndex), lineNumberWithOffsetFor)
});

@@ -79,0 +111,0 @@ }

2

package.json
{
"name": "cdocparser",
"version": "0.3.0-pre3",
"version": "0.3.0-pre4",
"description": "Extract C style comments and extract context from source",

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

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