Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
filter-css
Advanced tools
Readme
Filter CSS rules
npm install --save filter-css
const filterCss = require('filter-css');
const filtered = filterCss(<input>, <pattern>, <options>);
String
Can be a path to the CSS file or a raw CSS string.
String
,RegExp
, Function
or an Array
containing it.Patterns used to discard specific parts of the CSS.
The function is invoked with three arguments (context
, value
, node
).
context
: Current matching context. Could be one of ['type', 'media', 'selector', 'declarationProperty', 'declarationValue']
.value
: Current value.node
: The currently processed AST node generated by css
.Return true if the element should be discarded.
Per default filter-css
will be applied to all parts of the CSS. This behavior can be customized by disabling specific matchers.
Name | Type | Description |
---|---|---|
matchSelectors | boolean | Enable / disable matching of CSS selectors. |
matchTypes | boolean | Enable / disable matching of AST Node types like font-face |
matchDeclarationProperties | boolean | Enable / disable matching of CSS properties like background-image |
matchDeclarationValues | boolean | Enable / disable matching of CSS values like url(...) |
matchMedia | boolean | Enable / disable matching of media queries like min-device-pixel-ratio: 2 |
.bigBackground {
width: 100%;
height: 100%;
background-image: url('some/big/image.png');
}
@font-face {
font-family: 'My awesome font';
}
@media print {
...
}
const filterCss = require('filter-css');
filterCss('test/fixtures/test.css', [/url\(/,'@font-face',/print/]);
.bigBackground {
width: 100%;
height: 100%;
}
const filterCss = require('filter-css');
filterCss('test/fixtures/test.css', /.*/, {
matchSelectors: false,
matchTypes: false,
matchDeclarationProperties: false,
matchDeclarationValues: false,
matchMedia: true
});
const filterCss = require('filter-css');
filterCss('test/fixtures/test.css', (context, value, node) => {
return context === 'declarationValue' && value === "url('some/big/image.png')"
});
filterCss('test/fixtures/test.css', {
types: ['@font-face'],
selectors: ['.my-selector > p'],
declarations: [/url/]
});
filter-css works well with standard input.
cat test/fixture/test.css | filtercss --ignore @font-face
You can also pass in the file as an option.
filtercss test/fixture/test.css --ignore @font-face
See filtercss --help
for a full list of options.
MIT © Ben Zörb
FAQs
Filter CSS rules
The npm package filter-css receives a total of 9,720 weekly downloads. As such, filter-css popularity was classified as popular.
We found that filter-css demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.