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

postcss-discard-duplicates

Package Overview
Dependencies
Maintainers
5
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-discard-duplicates - npm Package Compare versions

Comparing version 2.1.0 to 4.0.0-nightly.2020.7.24

192

dist/index.js

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

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcss = require('postcss');
var _postcss = require("postcss");

@@ -10,130 +13,137 @@ function noop() {}

function trimValue(value) {
return value ? value.trim() : value;
return value ? value.trim() : value;
}
function empty(node) {
return !node.nodes.filter(function (child) {
return child.type !== 'comment';
}).length;
return !node.nodes.filter(child => child.type !== 'comment').length;
}
function equals(a, b) {
if (a.type !== b.type) {
if (a.type !== b.type) {
return false;
}
if (a.important !== b.important) {
return false;
}
if (a.raws && !b.raws || !a.raws && b.raws) {
return false;
}
switch (a.type) {
case 'rule':
if (a.selector !== b.selector) {
return false;
}
}
if (a.important !== b.important) {
break;
case 'atrule':
if (a.name !== b.name || a.params !== b.params) {
return false;
}
}
if (a.raws && !b.raws || !a.raws && b.raws) {
if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
return false;
}
}
switch (a.type) {
case 'rule':
if (a.selector !== b.selector) {
return false;
}
break;
case 'atrule':
if (a.name !== b.name || a.params !== b.params) {
return false;
}
if (a.raws && trimValue(a.raws.afterName) !== trimValue(b.raws.afterName)) {
return false;
}
if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
return false;
}
break;
if (a.raws && trimValue(a.raws.afterName) !== trimValue(b.raws.afterName)) {
return false;
}
break;
case 'decl':
if (a.prop !== b.prop || a.value !== b.value) {
return false;
}
case 'decl':
if (a.prop !== b.prop || a.value !== b.value) {
return false;
}
if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
return false;
}
break;
if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
return false;
}
break;
}
if (a.nodes) {
if (a.nodes.length !== b.nodes.length) {
return false;
}
if (a.nodes) {
if (a.nodes.length !== b.nodes.length) {
return false;
}
for (let i = 0; i < a.nodes.length; i++) {
if (!equals(a.nodes[i], b.nodes[i])) {
return false;
}
}
}
for (var i = 0; i < a.nodes.length; i++) {
if (!equals(a.nodes[i], b.nodes[i])) {
return false;
}
}
}
return true;
return true;
}
function dedupeRule(last, nodes) {
var index = nodes.indexOf(last) - 1;
let index = nodes.indexOf(last) - 1;
var _loop = function _loop() {
var node = nodes[index--];
if (node && node.type === 'rule' && node.selector === last.selector) {
last.each(function (child) {
if (child.type === 'decl') {
dedupeNode(child, node.nodes);
}
});
while (index >= 0) {
const node = nodes[index--];
if (empty(node)) {
node.remove();
}
if (node && node.type === 'rule' && node.selector === last.selector) {
last.each(child => {
if (child.type === 'decl') {
dedupeNode(child, node.nodes);
}
};
});
while (index >= 0) {
_loop();
if (empty(node)) {
node.remove();
}
}
}
}
function dedupeNode(last, nodes) {
var index = !!~nodes.indexOf(last) ? nodes.indexOf(last) - 1 : nodes.length - 1;
let index = ~nodes.indexOf(last) ? nodes.indexOf(last) - 1 : nodes.length - 1;
while (index >= 0) {
var _node = nodes[index--];
if (_node && equals(_node, last)) {
_node.remove();
}
while (index >= 0) {
const node = nodes[index--];
if (node && equals(node, last)) {
node.remove();
}
}
}
var handlers = {
rule: dedupeRule,
atrule: dedupeNode,
decl: dedupeNode,
comment: noop
const handlers = {
rule: dedupeRule,
atrule: dedupeNode,
decl: dedupeNode,
comment: noop
};
function dedupe(root) {
var nodes = root.nodes;
const {
nodes
} = root;
if (!nodes) {
return;
if (!nodes) {
return;
}
let index = nodes.length - 1;
while (index >= 0) {
let last = nodes[index--];
if (!last || !last.parent) {
continue;
}
var index = nodes.length - 1;
while (index >= 0) {
var last = nodes[index--];
if (!last || !last.parent) {
continue;
}
dedupe(last);
handlers[last.type](last, nodes);
}
dedupe(last);
handlers[last.type](last, nodes);
}
}
exports.default = (0, _postcss.plugin)('postcss-discard-duplicates', function () {
return dedupe;
});
module.exports = exports['default'];
var _default = (0, _postcss.plugin)('postcss-discard-duplicates', () => dedupe);
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-discard-duplicates",
"version": "2.1.0",
"version": "4.0.0-nightly.2020.7.24",
"description": "Discard duplicate rules in your CSS files with PostCSS.",

@@ -11,8 +11,5 @@ "main": "dist/index.js",

"scripts": {
"contributorAdd": "all-contributors add",
"contributorGenerate": "all-contributors generate",
"pretest": "eslint src",
"prepublish": "del-cli dist && babel src --out-dir dist --ignore /__tests__/",
"test": "ava src/__tests__",
"test-012": "ava src/__tests__"
"prebuild": "",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
"prepublish": ""
},

@@ -28,21 +25,5 @@ "keywords": [

"dependencies": {
"postcss": "^5.0.4"
"postcss": "^7.0.16"
},
"devDependencies": {
"all-contributors-cli": "^3.0.5",
"ava": "^0.17.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.5.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1"
},
"homepage": "https://github.com/ben-eb/postcss-discard-duplicates",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -53,9 +34,9 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/postcss-discard-duplicates",
"eslintConfig": {
"extends": "cssnano"
"repository": "cssnano/cssnano",
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"ava": {
"require": "babel-register"
"engines": {
"node": ">=6.9.0"
}
}
}

@@ -1,2 +0,2 @@

# [postcss][postcss]-discard-duplicates [![Build Status](https://travis-ci.org/ben-eb/postcss-discard-duplicates.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-discard-duplicates.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-discard-duplicates.svg)][deps]
# [postcss][postcss]-discard-duplicates

@@ -59,14 +59,8 @@ > Discard duplicate rules in your CSS files with PostCSS.

## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=TrySound) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/68302?v=3" width="100px;"/><br /><sub>Lee Houghton</sub>](https://github.com/asztal)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=asztal) | [<img src="https://avatars.githubusercontent.com/u/1737375?v=3" width="100px;"/><br /><sub>Andy Jansson</sub>](https://github.com/andyjansson)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=andyjansson) [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=andyjansson) |
| :---: | :---: | :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors] specification. Contributions of
any kind welcome!
## License

@@ -77,6 +71,2 @@

[all-contributors]: https://github.com/kentcdodds/all-contributors
[ci]: https://travis-ci.org/ben-eb/postcss-discard-duplicates
[deps]: https://gemnasium.com/ben-eb/postcss-discard-duplicates
[npm]: http://badge.fury.io/js/postcss-discard-duplicates
[postcss]: https://github.com/postcss/postcss
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