Package Exports
- extract-comments
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (extract-comments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
extract-comments 
Extract code comments from string or from a glob of files.
Install
Install with npm
$ npm i extract-comments --saveUsage
var extract = require('extract-comments');
// pass a string of javascript, CSS, LESS etc
extract(string);Example
var str = '/**\n * this is\n *\n * a comment\n*/\n\n\nvar foo = "bar";\n';
var comments = extract(str);
console.log(comments);
[{
type: 'block',
raw: '/**\n * this is\n *\n * a comment\n*/',
value: 'this is\na comment',
lines: [ 'this is', 'a comment' ],
loc: { start: { line: 1, pos: 0 }, end: { line: 5, pos: 33 } },
code:
{ line: 7,
loc: { start: { line: 7, pos: 36 }, end: { line: 7, pos: 52 } },
value: 'var foo = "bar";' }API
comments
Extract comments from the given string.
Params
string{String}options{Object}: Passfirst: trueto return after the first comment is found.returns{String}
Example
extract(str, options);block
Extract block comments from the given string.
Params
string{String}options{Object}: Passfirst: trueto return after the first comment is found.returns{String}
Example
extract.block(str, options);line
Extract line comments from the given string.
Params
string{String}options{Object}: Passfirst: trueto return after the first comment is found.returns{String}
Example
extract.line(str, options);first
Extract the first comment from the given string.
Params
string{String}options{Object}: Passfirst: trueto return after the first comment is found.returns{String}
Related
- code-context: Parse a string of javascript to determine the context for functions, variables and comments based… more | homepage
- esprima-extract-comments: Extract code comments from string or from a glob of files using esprima. | homepage
- parse-comments: Parse code comments from JavaScript or any language that uses the same format. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Tests
Run tests
Install dev dependencies:
$ npm i -d && npm testCoverage
As of December 25, 2015:
Statements : 100% (133/133)
Branches : 100% (32/32)
Functions : 100% (19/19)
Lines : 100% (132/132)Author
Jon Schlinkert
License
Copyright © 2014-2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb on December 25, 2015.