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

esprima-extract-comments

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprima-extract-comments - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

LICENSE

51

index.js

@@ -10,48 +10,12 @@ /*!

var fs = require('fs');
var extend = require('extend-shallow');
var esprima = require('esprima');
var mapFiles = require('map-files');
var _ = require('lodash');
/**
* Extract code comments from a glob of files:
*
* **Example:**
*
* ```js
* var extract = require('esprima-extract-comments');
* extract('lib/*.js');
* ```
*
* @param {String} `patterns` Glob patterns to used.
* @param {Object} `options` Options to pass to [esprima] or [globby], or [map-files].
* @return {Object} Object of code comments.
* @api public
*/
function extract(patterns, options) {
return mapFiles(patterns, _.extend({
// noop for mapFiles
rename: function(filepath) {
return filepath;
},
parse: function (filepath, options) {
var code = fs.readFileSync(filepath, 'utf8');
return extract.fromString(code, options);
}
}, options));
}
/**
* Extract code comments from the given `string`.
*
* **Example:**
*
* ```js
* var extract = require('esprima-extract-comments');
* extract.fromString('// this is a code comment');
* extract('// this is a code comment');
* ```
*
* @param {String} `string`

@@ -63,12 +27,5 @@ * @param {Object} `options` Options to pass to esprima.

extract.fromString = function(string, options) {
var opts = _.extend({comment: true, loc: true }, options);
module.exports = function extract(string, options) {
var opts = extend({comment: true, loc: true }, options);
return esprima.parse(string, opts).comments;
};
/**
* Expose `extract`
*/
module.exports = extract;
{
"name": "esprima-extract-comments",
"description": "Extract code comments from string or from a glob of files using esprima.",
"version": "0.1.2",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/esprima-extract-comments",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/esprima-extract-comments.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/esprima-extract-comments",
"bugs": {
"url": "https://github.com/jonschlinkert/esprima-extract-comments/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jonschlinkert/esprima-extract-comments/blob/master/LICENSE-MIT"
}
"license": "MIT",
"files": [
"index.js"
],
"keywords": [
"code",
"parse",
"javascript",
"block",
"context",
"comments",
"comment",
"extract",
"esprima",
"glob"
],
"main": "index.js",

@@ -40,13 +20,29 @@ "engines": {

"scripts": {
"test": "mocha -R spec"
"test": "mocha"
},
"devDependencies": {
"mocha": "~1.18.2",
"should": "^4.0.4"
"dependencies": {
"esprima": "^2.7.0",
"extend-shallow": "^2.0.1"
},
"dependencies": {
"esprima": "git+https://git@github.com/ariya/esprima",
"lodash": "^2.4.1",
"map-files": "^0.2.2"
"keywords": [
"block",
"code",
"comment",
"comments",
"context",
"esprima",
"extract",
"glob",
"javascript",
"parse"
],
"verb": {
"related": {
"list": [
"extract-comments",
"parse-comments",
"js-comments"
]
}
}
}
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