Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-colormin

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-colormin - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 2.1.3
* Updates postcss-value-parser to version 3 (thanks to @TrySound).
* Removes the dependency on colormin, conversion is now done in-module.
# 2.1.2

@@ -2,0 +7,0 @@

69

index.js
'use strict';
var colormin = require('colormin');
var colormin = require('./lib/colormin');
var postcss = require('postcss');
var parser = require('postcss-value-parser');
var stringify = parser.stringify;
var trim = parser.trim;
function optimise (decl) {
if (/^(?!font|filter|-webkit-tap-highlight-color)/.test(decl.prop)) {
decl.value = parser(decl.value).walk(function (node) {
if (node.type === 'function') {
if (/^(rgb|hsl)a?$/.test(node.value)) {
node.value = colormin(stringify(node));
node.type = 'word';
} else {
trim(node.nodes);
}
} else if (node.type === 'div' && node.value !== '/') {
node.before = '';
node.after = '';
} else if (node.type === 'space') {
node.value = ' ';
function extractColorArguments(nodes) {
var i, max;
var result = [];
for (i = 0, max = nodes.length; i < max; i += 1) {
if (nodes[i].type === 'word') {
result.push(parseFloat(nodes[i].value));
}
}
return result;
}
function reduceColor (decl) {
decl.value = parser(decl.value).walk(function (node) {
if (node.type === 'function') {
if (/^(rgb|hsl)a?$/.test(node.value)) {
node.value = colormin(node.value, extractColorArguments(node.nodes));
node.type = 'word';
} else {
node.value = colormin(node.value);
node.before = node.after = '';
}
}).toString();
}
} else if (node.type === 'word') {
node.value = colormin(node.value);
}
}).toString();
}
function reduceWhitespaces (decl) {
decl.value = parser(decl.value).walk(function (node) {
if (node.type === 'function' || node.type === 'div') {
node.before = node.after = '';
}
}).toString();
}
function transform (decl) {
if (decl.prop === '-webkit-tap-highlight-color') {

@@ -33,10 +47,5 @@ if (decl.value === 'inherit' || decl.value === 'transparent') {

}
decl.value = parser(decl.value).walk(function (node) {
if (node.type === 'function') {
trim(node.nodes);
} else if (node.type === 'div') {
node.before = '';
node.after = '';
}
}).toString();
reduceWhitespaces(decl);
} else if (/^(?!font|filter)/.test(decl.prop)) {
reduceColor(decl);
}

@@ -47,4 +56,4 @@ }

return function (css) {
css.walkDecls(optimise);
css.walkDecls(transform);
};
});
{
"name": "postcss-colormin",
"version": "2.1.2",
"description": "Minify colors in your CSS files with PostCSS and colormin.",
"version": "2.1.3",
"description": "Minify colors in your CSS files with PostCSS.",
"main": "index.js",

@@ -35,6 +35,7 @@ "files": [

"dependencies": {
"colormin": "^1.0.4",
"colr-convert": "^1.0.5",
"css-color-names": "0.0.2",
"postcss": "^5.0.4",
"postcss-value-parser": "^2.0.2"
"postcss-value-parser": "^3.0.2"
}
}
# [postcss][postcss]-colormin [![Build Status](https://travis-ci.org/ben-eb/postcss-colormin.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-colormin.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-colormin.svg)][deps]
> Minify colors in your CSS files with PostCSS and [colormin][colormin].
> Minify colors in your CSS files with PostCSS.

@@ -36,3 +36,2 @@ ## Install

[colormin]: https://github.com/ben-eb/colormin
[ci]: https://travis-ci.org/ben-eb/postcss-colormin

@@ -39,0 +38,0 @@ [deps]: https://gemnasium.com/ben-eb/postcss-colormin

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc