Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
postcss-helpers
Advanced tools
Some general purpose helpers for PostCSS, created to make working with url() and @import values more easy.
Some general purpose helpers for PostCSS, created to make working with url() and @import values more easy. Can be used without PostCSS.
npm install postcss-helpers
Returns new UrlsHelper object from the rule string with one or more url() (see description below).
Returns new ImportHelper object from the @import value string (see description below).
Object for manipulating values of rules with one or multiple url().
Returns original rule that it was created with.
Returns Array of all original URI in string. NOT mutated URIs.
Array of one or more urijs objects that can be used for URI manipulations. If there is no url() in the rule returns false.
For example you can use UrlsHelper.URIS[0].href() to get value for the first url() and UrlsHelper.URIS[0].href('new_uri') to set new URI value. See full documentation.
After you finished changing values of the URIS you can get modified rule text with this command.
Object for manipulating values of @import at-rules.
Returns original rule that it was created with.
Returns original URI from string. NOT mutated URI.
urijs objects that can be used for URI manipulations. If there is no url() in the rule returns false.
For example you can use ImportHelper.URI.href() to get import value and ImportHelper.URI.href('new_uri') to set new URI value. See full documentation.
After you finished changing values of the URI you can get modified rule text with this command.
Returns media query from original string.
Replace old media query or creates new one.
Returns current media query from string.
Collection of some useful RegExps based on CSS specification grammar rules: http://www.w3.org/TR/CSS21/grammar.html
Modify string with multiple url() fragments:
var helpers = require( 'postcss-helpers' );
var rule = 'url(logo1.png)', url( 'logo2.png' ), url( "logo3.png");
var helper = helpers.createUrlsHelper( rule );
helper.URIS.forEach( function( uri ) {
uri.suffix( 'jpeg' );
} );
var modifiedRule = helper.getModifiedRule(); // url(logo1.jpeg)', url( 'logo2.jpeg' ), url( "logo3.jpeg")
Modify @import value:
var helpers = require( 'postcss-helpers' );
var rule = '"src/print.css" print';
var helper = helpers.createImportHelper( rule );
helper.URI.directory( 'dist' );
helper.getMediaQuery(); // print
helper.setMediaQuery( 'screen' );
var modifiedRule = helper.getModifiedRule(); // "dist/print.css" screen
Test if string contains url() fragments:
var helpers = require( 'postcss-helpers' );
var rule = 'url(logo1.png)', url( 'logo2.png' ), url( "logo3.png");
helpers.regexp.URIS.test( rule ); // true
UrlsHelper() and ImportHelper() will not escape quotes in the new URI values so escape them yourself.
See CHANGELOG for detailed changes.
FAQs
Some general purpose helpers for PostCSS, created to make working with url() and @import values more easy.
The npm package postcss-helpers receives a total of 19,420 weekly downloads. As such, postcss-helpers popularity was classified as popular.
We found that postcss-helpers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.