esprima-extract-comments
Advanced tools
Comparing version 0.1.2 to 0.2.0
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" | ||
] | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
0
0
1
5689
4
25
104
1
+ Addedextend-shallow@^2.0.1
+ Addedesprima@2.7.3(transitive)
+ Addedextend-shallow@2.0.1(transitive)
+ Addedis-extendable@0.1.1(transitive)
- Removedlodash@^2.4.1
- Removedmap-files@^0.2.2
- Removedarray-differ@0.1.0(transitive)
- Removedarray-union@0.1.0(transitive)
- Removedarray-uniq@0.1.1(transitive)
- Removedasync@0.9.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedglob@4.5.3(transitive)
- Removedglobby@0.1.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlodash@2.4.2(transitive)
- Removedmap-files@0.2.2(transitive)
- Removedminimatch@2.0.10(transitive)
- Removednormalize-path@0.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedrelative@0.1.6(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedesprima@^2.7.0