Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
multilang-extract-comments
Advanced tools
Extract comments from source files of various languages
Extract comments from source files of various languages
multilang-extract-comments is a package for extracting comments from source-code. It is compatible with the
extract-comments
-package by Jon Schlinkert:
It provides an extended API, which allows you to extract comments not only from JavaScript files, but also from Python, C, Handlebars etc.
The module was originally forked from extract-comments,
with the purpose to allow verb to extract jsdoc-like comments from file
other than JavaScript-files. In the end, the module was a complete rewrite of the original module. Now the only
common file is spec/javascript-spec.js
which is more or less equal to Jon Schlinkert's
extract-comments/test.js
.
The primary targets are Handlebars-files, for documenting bootprint template-modules.
For the following string:
/**
* A javascript multiline-comment
* with multiple lines
*/
function aLineOfCode () {
}
// A single line comments
// More of it directly below
function anotherFunction () {
aLineOfCode()
}
anotherFunction()
and the following code
var comments = require('multilang-extract-comments')(string);
The variable comments
now contains:
{
"1": {
"begin": 1,
"end": 4,
"codeStart": 5,
"content": "A javascript multiline-comment\nwith multiple lines\n",
"info": {
"type": "multiline",
"apidoc": true
},
"code": "function aLineOfCode () {"
},
"8": {
"begin": 8,
"end": 9,
"codeStart": 10,
"content": "A single line comments\nMore of it directly below\n",
"info": {
"type": "singleline"
},
"code": "function anotherFunction () {"
}
}
Also have a look at the usage example of extract-comments
For the following string:
Some code here
and the following code
var comments = require('multilang-extract-comments')(string, { filename: 'handlebars.hbs'});
The variable comments
now contains:
{
"1": {
"begin": 1,
"end": 4,
"codeStart": 5,
"content": "This is an example\nof a handlebars multiline-comment.\n",
"info": {
"type": "multiline"
},
"code": "Some code here"
}
}
For the following string:
<#
A powershell multiline-comment
with multiple lines
#>
Function aLineOfCode {
}
# A single line comment
# More of it directly below
Function anotherFunction () {
Write-Output "test"
}
anotherFunction
and the following code
var options = {
pattern: {
name: 'Powershell',
nameMatchers: ['.ps1'],
singleLineComment: [{ start: '#' }],
multiLineComment: [{ start: '<#', middle: '', end: '#>'}]
}
}
var comments = require('multilang-extract-comments')(string,options);
The variable comments
now contains:
{
"1": {
"begin": 1,
"end": 4,
"codeStart": 5,
"content": "A powershell multiline-comment\nwith multiple lines\n ",
"info": {
"type": "multiline"
},
"code": "Function aLineOfCode {"
},
"8": {
"begin": 8,
"end": 9,
"codeStart": 10,
"content": "A single line comment\nMore of it directly below\n",
"info": {
"type": "singleline"
},
"code": "Function anotherFunction () {"
}
}
Also have a look at the usage example of extract-comments
TODO
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
see CONTRIBUTING.md
see CHANGELOG.md
Nils Knappmeier
Copyright © 2015-2017 Nils Knappmeier Released under the MIT license.
FAQs
Extract comments from source files of various languages
The npm package multilang-extract-comments receives a total of 13,714 weekly downloads. As such, multilang-extract-comments popularity was classified as popular.
We found that multilang-extract-comments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.