add lisp packages

This commit is contained in:
2020-12-05 21:29:49 +01:00
parent 85e20365ae
commit a6e2395755
7272 changed files with 1363243 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
'use strict';
var isRegExp = require('is-regexp');
module.exports = function (str, opts) {
str = str.toString();
opts = opts || {};
var preserveFilter;
var comment = '';
var currentChar = '';
var insideString = false;
var preserveImportant = !(opts.preserve === false || opts.all === true);
var ret = '';
if (typeof opts.preserve === 'function') {
preserveImportant = false;
preserveFilter = opts.preserve;
} else if (isRegExp(opts.preserve)) {
preserveImportant = false;
preserveFilter = function (comment) {
return opts.preserve.test(comment);
};
}
for (var i = 0; i < str.length; i++) {
currentChar = str[i];
if (str[i - 1] !== '\\') {
if (currentChar === '"' || currentChar === '\'') {
if (insideString === currentChar) {
insideString = false;
} else if (!insideString) {
insideString = currentChar;
}
}
}
// find beginning of /* type comment
if (!insideString && currentChar === '/' && str[i + 1] === '*') {
// ignore important comment when configured to preserve comments using important syntax: /*!
if (!(preserveImportant && str[i + 2] === '!')) {
var j = i + 2;
// iterate over comment
for (; j < str.length; j++) {
// find end of comment
if (str[j] === '*' && str[j + 1] === '/') {
if (preserveFilter) {
// evaluate comment text
ret = preserveFilter(comment) ? ret + ('/*' + comment + '*/') : ret;
comment = '';
}
break;
}
// store comment text to be evaluated by the filter when the end of the comment is reached
if (preserveFilter) {
comment += str[j];
}
}
// resume iteration over CSS string from the end of the comment
i = j + 1;
continue;
}
}
ret += currentChar;
}
return ret;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,43 @@
{
"name": "strip-css-comments",
"version": "3.0.0",
"description": "Strip comments from CSS",
"license": "MIT",
"repository": "sindresorhus/strip-css-comments",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && node test.js",
"bench": "matcha bench.js"
},
"files": [
"index.js"
],
"keywords": [
"css",
"style",
"stylesheet",
"strip",
"remove",
"delete",
"trim",
"comments",
"preprocess",
"transform",
"string"
],
"dependencies": {
"is-regexp": "^1.0.0"
},
"devDependencies": {
"ava": "0.0.4",
"matcha": "^0.6.0",
"xo": "*"
}
}

View File

@@ -0,0 +1,87 @@
# strip-css-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-css-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-css-comments)
> Strip comments from CSS
Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-css-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-css-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-css-comments) plugin.
## Usage
```
$ npm install --save strip-css-comments
```
```js
var stripCssComments = require('strip-css-comments');
// by default important comments `/*!` are preserved
stripCssComments('/*! <copyright> */ body { /* unicorns */color: hotpink; }');
//=> '/*! <copyright> */ body { color: hotpink; }'
// `preserve: false` will strip all comments including `/*!`
stripCssComments(
'/*! <copyright> */ body { /* unicorns */color: hotpink; }',
{preserve: false}
);
//=> 'body { color: hotpink; }'
// preserve comments based on a regex
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{preserve: /^#/}
);
//=> '/*# preserved */ body { color: hotpink; }'
// preserve comments based on the return value of the supplied function
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{
preserve: function (comment) {
return comment.charAt(0) === '#';
}
}
);
//=> '/*# preserved */ body { color: hotpink; }'
```
## API
### stripCssComments(input, [options])
## input
*Required*
Type: `string`
String with CSS.
## options
### preserve
Type: `boolean`, `RegExp`, `function`
Default: `true`
- `true` - Preserve comments that use the `/*! */` syntax
- `false` - Strip all comments
- `RegExp` - Preserve comments where the comment body matches a regular expression.
- `Function` - Preserve comments for which a function returns `true`. The function is called on each comment, gets the comment body as the first argument, and is expected to return a boolean of whether to preserve the comment.
## Benchmark
```
$ npm run bench
```
## Related
- [strip-css-comments-cli](https://github.com/sindresorhus/strip-css-comments-cli) - CLI for this module
- [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) - Strip comments from JSON
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)