Socket
Socket
Sign inDemoInstall

postcss-colormin

Package Overview
Dependencies
Maintainers
5
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 4.0.0-rc.2 to 4.0.0

20

dist/colours.js

@@ -21,22 +21,18 @@ 'use strict';

var shorter = function shorter(a, b) {
return (a && a.length < b.length ? a : b).toLowerCase();
};
const shorter = (a, b) => (a && a.length < b.length ? a : b).toLowerCase();
exports.default = function (colour) {
var legacy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
exports.default = (colour, legacy = false) => {
try {
var parsed = (0, _color2.default)(colour.toLowerCase());
var alpha = parsed.alpha();
const parsed = (0, _color2.default)(colour.toLowerCase());
const alpha = parsed.alpha();
if (alpha === 1) {
var toHex = (0, _toShorthand2.default)(parsed.hex().toLowerCase());
const toHex = (0, _toShorthand2.default)(parsed.hex().toLowerCase());
return shorter(_keywords2.default[toHex], toHex);
} else {
var rgb = parsed.rgb();
const rgb = parsed.rgb();
if (!legacy && !rgb.color[0] && !rgb.color[1] && !rgb.color[2] && !alpha) {
return 'transparent';
}
var hsla = parsed.hsl().round().string();
var rgba = rgb.string();
let hsla = parsed.hsl().round().string();
let rgba = rgb.string();
return hsla.length < rgba.length ? hsla : rgba;

@@ -43,0 +39,0 @@ }

27

dist/index.js

@@ -26,4 +26,4 @@ 'use strict';

function walk(parent, callback) {
parent.nodes.forEach(function (node, index) {
var bubble = callback(node, index, parent);
parent.nodes.forEach((node, index) => {
const bubble = callback(node, index, parent);
if (node.nodes && bubble !== false) {

@@ -39,15 +39,14 @@ walk(node, callback);

}
var ast = (0, _postcssValueParser2.default)(decl.value);
walk(ast, function (node, index, parent) {
const ast = (0, _postcssValueParser2.default)(decl.value);
walk(ast, (node, index, parent) => {
if (node.type === 'function') {
if (/^(rgb|hsl)a?$/.test(node.value)) {
var value = node.value;
if (/^(rgb|hsl)a?$/i.test(node.value)) {
const { value } = node;
node.value = (0, _colours2.default)((0, _postcssValueParser.stringify)(node), legacy);
node.type = 'word';
var next = parent.nodes[index + 1];
if (node.value !== value && next && next.type === 'word') {
const next = parent.nodes[index + 1];
if (node.value !== value && next && (next.type === 'word' || next.type === 'function')) {
parent.nodes.splice(index + 1, 0, { type: 'space', value: ' ' });
}
} else if (node.value === 'calc') {
} else if (node.value.toLowerCase() === 'calc') {
return false;

@@ -73,6 +72,6 @@ }

exports.default = _postcss2.default.plugin('postcss-colormin', function () {
return function (css, result) {
var resultOpts = result.opts || {};
var browsers = (0, _browserslist2.default)(null, {
exports.default = _postcss2.default.plugin('postcss-colormin', () => {
return (css, result) => {
const resultOpts = result.opts || {};
const browsers = (0, _browserslist2.default)(null, {
stats: resultOpts.stats,

@@ -79,0 +78,0 @@ path: __dirname,

@@ -7,3 +7,3 @@ 'use strict';

exports.default = function (hex) {
exports.default = hex => {
if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) {

@@ -10,0 +10,0 @@ return '#' + hex[2] + hex[4] + hex[6];

{
"name": "postcss-colormin",
"version": "4.0.0-rc.2",
"version": "4.0.0",
"description": "Minify colors in your CSS files with PostCSS.",

@@ -25,7 +25,7 @@ "main": "dist/index.js",

"babel-cli": "^6.0.0",
"cross-env": "^3.0.0",
"cross-env": "^5.0.0",
"css-color-names": "0.0.4",
"write-file": "^1.0.0"
},
"homepage": "https://github.com/ben-eb/cssnano",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -36,6 +36,6 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/cssnano",
"repository": "cssnano/cssnano",
"dependencies": {
"browserslist": "^2.0.0",
"color": "^1.0.0",
"browserslist": "^4.0.0",
"color": "^3.0.0",
"has": "^1.0.0",

@@ -46,7 +46,7 @@ "postcss": "^6.0.0",

"bugs": {
"url": "https://github.com/ben-eb/cssnano/issues"
"url": "https://github.com/cssnano/cssnano/issues"
},
"engines": {
"node": ">=4"
"node": ">=6.9.0"
}
}

@@ -37,3 +37,3 @@ # [postcss][postcss]-colormin

See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md).
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).

@@ -40,0 +40,0 @@

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