# comments-extractor

> Extract comments from glob of files, annotated or not

Latest version **1.0.10** (published 2021-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install comments-extractor
pnpm add comments-extractor
yarn add comments-extractor
bun add comments-extractor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2021-01-04 |
| First published | 2018-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Danila Loginov |
| Maintainers | loginov-rocks |
| Keywords | annotations, comments, extractor |

## Links

- npm: https://www.npmjs.com/package/comments-extractor
- Repository: https://github.com/loginov-rocks/comments-extractor
- Issues: https://github.com/loginov-rocks/comments-extractor/issues
- npm.io page: https://npm.io/package/comments-extractor

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [esprima](https://npm.io/package/esprima.md) ^4.0.1

## Recent versions

- 1.0.10 (latest) — 2021-01-04
- 1.0.9 — 2019-10-01
- 1.0.8 — 2019-06-17
- 1.0.7 — 2019-02-25
- 1.0.5 — 2018-12-31
- 1.0.4 — 2018-09-30
- 1.0.3 — 2018-08-11
- 1.0.2 — 2018-02-04
- 1.0.1 — 2018-01-28
- 1.0.0 — 2018-01-28

## README

# comments-extractor

[![npm](https://img.shields.io/npm/v/comments-extractor)](https://www.npmjs.com/package/comments-extractor)
[![CI](https://github.com/loginov-rocks/comments-extractor/workflows/CI/badge.svg)](https://github.com/loginov-rocks/comments-extractor/actions)
[![Coverage Status](https://coveralls.io/repos/github/loginov-rocks/comments-extractor/badge.svg?branch=main)](https://coveralls.io/github/loginov-rocks/comments-extractor?branch=main)

Extract comments from glob of files, annotated or not.

## Quick Start

### Install

```sh
npm install comments-extractor
```

### Use

```js
const CommentsExtractor = require('comments-extractor');
const extractor = new CommentsExtractor('./**/*.js', 'todo');
const todos = extractor.extract();

console.log(todos);
// Output:
// Map {
//   './example-block.js' => [ { type: 'Block', value: '*\n * @TODO: Write this block.\n ' } ],
//   './example-line.js' => [ { type: 'Line', value: ' @TODO: Write this line.' } ]
// }
```

## API

### `CommentsExtractor`

Comments Extractor class.

**Kind**: global class

* [CommentsExtractor](#commentsextractor)
  * [new CommentsExtractor(pattern, [annotation], [options], [esprimaClass], [fsClass], [globClass])](#new-commentsextractorpattern-annotation-options-esprimaclass-fsclass-globclass)
  * [extract() ⇒ Map.<string, Array>](#extract--mapstring-array)

---

#### `new CommentsExtractor(pattern, [annotation], [options], [esprimaClass], [fsClass], [globClass])`

Comments Extractor constructor.

| Parameter      | Type     | Default   | Description  |
| -------------- | -------- | --------- | ------------ |
| pattern        | `string` |           | Glob pattern |
| [annotation]   | `string` | `''`      | Annotation   |
| [options]      | `Object` | `{}`      | Glob options |
| [esprimaClass] | `*`      | `esprima` |              |
| [fsClass]      | `*`      | `fs`      |              |
| [globClass]    | `*`      | `glob`    |              |

---

#### `extract()` ⇒ `Map.<string, Array>`

Extract comments.

**Kind**: instance method of `CommentsExtractor`

**Returns**: `Map.<string, Array>`, where key is a filepath and value is an array of comments

---
_Source: https://npm.io/package/comments-extractor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
