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

postcss-discard-duplicates

Package Overview
Dependencies
Maintainers
2
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 1.1.3 to 1.1.4

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 1.1.4
* Improved performance by making all AST iterations in a single pass.
# 1.1.3

@@ -2,0 +6,0 @@

44

index.js

@@ -5,27 +5,14 @@ 'use strict';

function filterIdent (cache) {
return function (node) {
// Ensure we don't dedupe in different contexts
var sameContext = node.parent.type === cache.parent.type;
// Ensure that at rules have exactly the same name; this accounts for
// vendor prefixes
if (node.parent.type !== 'root') {
sameContext = sameContext && node.parent.name === cache.parent.name;
}
return sameContext && String(node) === String(cache);
};
}
function dedupe (node) {
if (node.nodes) { node.each(dedupe); }
function dedupe (callback) {
var cache = [];
return function (rule) {
if (!callback || callback.call(this, rule)) {
var cached = cache.filter(filterIdent(rule));
if (cached.length) {
cached[0].removeSelf();
cache.splice(cache.indexOf(cached[0]), 1);
}
cache.push(rule);
var nodes = node.parent.nodes.filter(function (n) {
return String(n) === String(node);
});
nodes.forEach(function (n, i) {
if (i !== nodes.length - 1) {
n.removeSelf();
}
};
});
}

@@ -35,13 +22,4 @@

return function (css) {
css.eachAtRule(dedupe());
css.eachAtRule(function (rule) {
rule.eachRule(dedupe());
});
css.eachRule(function (rule) {
rule.eachDecl(dedupe());
});
css.eachRule(dedupe(function (rule) {
return rule.parent.type === 'root';
}));
css.each(dedupe);
};
});
{
"name": "postcss-discard-duplicates",
"version": "1.1.3",
"version": "1.1.4",
"description": "Discard duplicate rules in your CSS files with PostCSS.",
"main": "index.js",
"scripts": {
"lint": "jshint index.js --reporter node_modules/jshint-stylish/stylish.js",
"test": "tape test.js | tap-spec"

@@ -19,9 +18,7 @@ },

"dependencies": {
"postcss": "^4.1.10"
"postcss": "^4.1.16"
},
"devDependencies": {
"jshint": "^2.6.3",
"jshint-stylish": "^1.0.1",
"tap-spec": "^2.2.2",
"tape": "^3.5.0"
"tap-spec": "^4.0.2",
"tape": "^4.1.0"
},

@@ -34,6 +31,3 @@ "homepage": "https://github.com/ben-eb/postcss-discard-duplicates",

},
"repository": {
"type": "git",
"url": "git://github.com/ben-eb/postcss-discard-duplicates.git"
}
"repository": "ben-eb/postcss-discard-duplicates"
}
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