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

esprima-extract-comments

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprima-extract-comments

Extract code comments from string or from a glob of files using esprima.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
decreased by-39.38%
Maintainers
1
Weekly downloads
 
Created
Source

esprima-extract-comments NPM version

Extract code comments from string or from a glob of files using esprima.

Install

Install with npm:
npm i esprima-extract-comments --save-dev

Run tests

Run

npm test

API

extract

Extract code comments from a glob of files:

  • patterns {String}: Glob patterns to used.
  • options {Object}: Options to pass to esprima or globby, or map-files.
  • returns {Object}: Object of code comments.

Example:

var extract = require('esprima-extract-comments');
extract('lib/*.js');

.fromString

Extract code comments from the given string.

  • string {String}
  • options {Object}: Options to pass to esprima.
  • returns {Object}: Object of code comments.

Example:

var extract = require('esprima-extract-comments');
extract.fromString('// this is a code comment');

You may also pass a custom rename function on the options to change the key of each object returned. See map-files for more details and available options.

Example results

{ 'test/fixtures/assemble.js':
   [ { type: 'Block',
       value: '!\n * assemble <https://github.com/assemble/assemble>\n *\n * Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors.\n * Licensed under the MIT license.\n ',
       loc: { start: { line: 1, column: 0 }, end: { line: 6, column: 3 } } },
     { type: 'Line',
       value: ' Module dependencies',
       loc:
        { start: { line: 10, column: 0 },
          end: { line: 10, column: 22 } } },
     { type: 'Line',
       value: ' Local modules.',
       loc:
        { start: { line: 39, column: 0 },
          end: { line: 39, column: 17 } } },
     { type: 'Line',
       value: ' Plugins and middleware',
       loc:
        { start: { line: 44, column: 0 },
          end: { line: 44, column: 25 } } },
     { type: 'Block',
       value: '*\n * Set the current working directory for all paths.\n * Default is `process.cwd()`, this does not need to\n * be changed unless you require something different.\n *\n * ```js\n * assemble.cwd(\'bench\');\n * ```\n *\n * @param  {String|Array} `args` File path or paths.\n * @return {String}\n * @api public\n ',
       loc:
        { start: { line: 414, column: 0 },
          end: { line: 426, column: 3 } } },

Or when extract.fromString() is used:

{ type: 'Block',
     value: '!\n * assemble <https://github.com/assemble/assemble>\n *\n * Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors.\n * Licensed under the MIT license.\n ',
     loc: { start: { line: 1, column: 0 }, end: { line: 6, column: 3 } } },
   { type: 'Line',
     value: ' Module dependencies',
     loc:
      { start: { line: 10, column: 0 },
        end: { line: 10, column: 22 } } },
   { type: 'Line',
     value: ' Local modules.',
     loc:
      { start: { line: 39, column: 0 },
        end: { line: 39, column: 17 } } },
   { type: 'Line',
     value: ' Plugins and middleware',
     loc:
      { start: { line: 44, column: 0 },
        end: { line: 44, column: 25 } } }

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on September 24, 2014.

Keywords

FAQs

Package last updated on 24 Sep 2014

Did you know?

Socket

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.

Install

Related posts

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