source: frontend/node_modules/strip-comments/README.md@ 9af201e

Last change on this file since 9af201e was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 8.2 KB
Line 
1# strip-comments [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/strip-comments.svg?style=flat)](https://www.npmjs.com/package/strip-comments) [![NPM monthly downloads](https://img.shields.io/npm/dm/strip-comments.svg?style=flat)](https://npmjs.org/package/strip-comments) [![NPM total downloads](https://img.shields.io/npm/dt/strip-comments.svg?style=flat)](https://npmjs.org/package/strip-comments) [![Build Status](https://travis-ci.org/jonschlinkert/strip-comments.svg?branch=master)](https://travis-ci.org/jonschlinkert/strip-comments)
2
3> Strip line and/or block comments from a string. Blazing fast, and works with JavaScript, Sass, CSS, Less.js, and a number of other languages.
4
5Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
6
7- [Install](#install)
8- [What does this do?](#what-does-this-do)
9- [Usage](#usage)
10- [API](#api)
11- [About](#about)
12
13_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
14
15## Install
16
17Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=10):
18
19```sh
20$ npm install --save strip-comments
21```
22
23## What does this do?
24
25Takes a string and returns a new string with comments removed. Works with line comments and/or block comments. Optionally removes the first comment only or ignores protected comments.
26
27Works with:
28
29* ada
30* apl
31* applescript
32* c
33* csharp
34* css
35* hashbang
36* haskell
37* html
38* java
39* javascript
40* less
41* lua
42* matlab
43* ocaml
44* pascal
45* perl
46* php
47* python
48* ruby
49* sass
50* shebang
51* sql
52* swift
53* typscript
54* xml
55
56## Usage
57
58By default all comments are stripped.
59
60```js
61const strip = require('strip-comments');
62const str = strip('const foo = "bar";// this is a comment\n /* me too *\/');
63console.log(str);
64// => 'const foo = "bar";\n'
65```
66
67For more use-cases see the [tests](./test/test.js)
68
69## API
70
71### [strip](index.js#L33)
72
73Strip all code comments from the given `input`, including protected comments that start with `!`, unless disabled by setting `options.keepProtected` to true.
74
75**Params**
76
77* `input` **{String}**: string from which to strip comments
78* `options` **{Object}**: optional options, passed to [extract-comments](https://github.com/jonschlinkert/extract-comments)
79
80- `line` **{Boolean}**: if `false` strip only block comments, default `true`
81- `block` **{Boolean}**: if `false` strip only line comments, default `true`
82- `keepProtected` **{Boolean}**: Keep ignored comments (e.g. `/*!` and `//!`)
83- `preserveNewlines` **{Boolean}**: Preserve newlines after comments are stripped
84* `returns` **{String}**: modified input
85
86**Example**
87
88```js
89const str = strip('const foo = "bar";// this is a comment\n /* me too */');
90console.log(str);
91// => 'const foo = "bar";'
92```
93
94### [.block](index.js#L54)
95
96Strip only block comments.
97
98**Params**
99
100* `input` **{String}**: string from which to strip comments
101* `options` **{Object}**: pass `opts.keepProtected: true` to keep ignored comments (e.g. `/*!`)
102* `returns` **{String}**: modified string
103
104**Example**
105
106```js
107const strip = require('..');
108const str = strip.block('const foo = "bar";// this is a comment\n /* me too */');
109console.log(str);
110// => 'const foo = "bar";// this is a comment'
111```
112
113### [.line](index.js#L74)
114
115Strip only line comments.
116
117**Params**
118
119* `input` **{String}**: string from which to strip comments
120* `options` **{Object}**: pass `opts.keepProtected: true` to keep ignored comments (e.g. `//!`)
121* `returns` **{String}**: modified string
122
123**Example**
124
125```js
126const str = strip.line('const foo = "bar";// this is a comment\n /* me too */');
127console.log(str);
128// => 'const foo = "bar";\n/* me too */'
129```
130
131### [.first](index.js#L95)
132
133Strip the first comment from the given `input`. Or, if `opts.keepProtected` is true, the first non-protected comment will be stripped.
134
135**Params**
136
137* `input` **{String}**
138* `options` **{Object}**: pass `opts.keepProtected: true` to keep comments with `!`
139* `returns` **{String}**
140
141**Example**
142
143```js
144const output = strip.first(input, { keepProtected: true });
145console.log(output);
146// => '//! first comment\nfoo; '
147```
148
149### [.block](index.js#L116)
150
151Parses a string and returns a basic CST (Concrete Syntax Tree).
152
153**Params**
154
155* `input` **{String}**: string from which to strip comments
156* `options` **{Object}**: pass `opts.keepProtected: true` to keep ignored comments (e.g. `/*!`)
157* `returns` **{String}**: modified string
158
159**Example**
160
161```js
162const strip = require('..');
163const str = strip.block('const foo = "bar";// this is a comment\n /* me too */');
164console.log(str);
165// => 'const foo = "bar";// this is a comment'
166```
167
168## About
169
170<details>
171<summary><strong>Contributing</strong></summary>
172
173Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
174
175</details>
176
177<details>
178<summary><strong>Running Tests</strong></summary>
179
180Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
181
182```sh
183$ npm install && npm test
184```
185
186</details>
187
188<details>
189<summary><strong>Building docs</strong></summary>
190
191_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
192
193To generate the readme, run the following command:
194
195```sh
196$ npm install -g verbose/verb#dev verb-generate-readme && verb
197```
198
199</details>
200
201### Related projects
202
203You might also be interested in these projects:
204
205* [code-context](https://www.npmjs.com/package/code-context): Parse a string of javascript to determine the context for functions, variables and comments based… [more](https://github.com/jonschlinkert/code-context) | [homepage](https://github.com/jonschlinkert/code-context "Parse a string of javascript to determine the context for functions, variables and comments based on the code that follows.")
206* [extract-comments](https://www.npmjs.com/package/extract-comments): Uses esprima to extract line and block comments from a string of JavaScript. Also optionally… [more](https://github.com/jonschlinkert/extract-comments) | [homepage](https://github.com/jonschlinkert/extract-comments "Uses esprima to extract line and block comments from a string of JavaScript. Also optionally parses code context (the next line of code after a comment).")
207* [parse-code-context](https://www.npmjs.com/package/parse-code-context): Fast and simple way to parse code context for use with documentation from code comments… [more](https://github.com/jonschlinkert/parse-code-context) | [homepage](https://github.com/jonschlinkert/parse-code-context "Fast and simple way to parse code context for use with documentation from code comments. Parses context from a single line of JavaScript, for functions, variable declarations, methods, prototype properties, prototype methods etc.")
208* [parse-comments](https://www.npmjs.com/package/parse-comments): Parse code comments from JavaScript or any language that uses the same format. | [homepage](https://github.com/jonschlinkert/parse-comments "Parse code comments from JavaScript or any language that uses the same format.")
209
210### Contributors
211
212| **Commits** | **Contributor** |
213| --- | --- |
214| 82 | [jonschlinkert](https://github.com/jonschlinkert) |
215| 4 | [tunnckoCore](https://github.com/tunnckoCore) |
216| 2 | [mk-pmb](https://github.com/mk-pmb) |
217| 1 | [kgryte](https://github.com/kgryte) |
218| 1 | [briandipalma](https://github.com/briandipalma) |
219| 1 | [epicoxymoron](https://github.com/epicoxymoron) |
220| 1 | [XuluWarrior](https://github.com/XuluWarrior) |
221
222### Author
223
224**Jon Schlinkert**
225
226* [GitHub Profile](https://github.com/jonschlinkert)
227* [Twitter Profile](https://twitter.com/jonschlinkert)
228* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
229
230### License
231
232Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
233Released under the [MIT License](LICENSE).
234
235***
236
237_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 13, 2019._
Note: See TracBrowser for help on using the repository browser.