
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
es-comments
Advanced tools
Parses a list of comments from an ECMAScript (JavaScript) source file. 0 dependencies, 417 bytes minified + gzipped.
npm install es-comments
const parseESComments = require('es-comments');
const someSourceCode = `
// Some single line comment
console.log('hello world');
`;
const comments = parseESComments(someSourceCode);
/* Outputs:
[
{
"value": "// Some single line comment",
"start": 9,
"end": 36
}
]
*/
Benchmarks run on a mid-2015 MacBook Pro. Benchmarks compare running time to other similar npm packages.
+--------------+----------------------------+------------------+---------------+---------------+
| │ es-comments (this package) │ extract-comments │ get-comments │ comment-regex |
+--------------+----------------------------+------------------+---------------+---------------+
| jQuery 1.7.2 │ 49.36 ops/sec │ 9.27 ops/sec │ 22.05 ops/sec │ 1,474 ops/sec |
+--------------+----------------------------+------------------+---------------+---------------+
tl;dr: If location information is not necessary, and some misses are ok, use a RegExp. Otherwise, this package is a good alternative.
FAQs
Parses single and multiline comments from an ECMAScript source file
The npm package es-comments receives a total of 2,580 weekly downloads. As such, es-comments popularity was classified as popular.
We found that es-comments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.