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

postcss-merge-idents

Package Overview
Dependencies
Maintainers
7
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-merge-idents - npm Package Compare versions

Comparing version 2.1.7 to 4.0.0-nightly.2020.1.9

174

dist/index.js

@@ -1,116 +0,100 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _has = _interopRequireDefault(require("has"));
var _has = require('has');
var _postcss = require("postcss");
var _has2 = _interopRequireDefault(_has);
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
var _postcss = require('postcss');
var _cssnanoUtils = require("cssnano-utils");
var _postcssValueParser = require('postcss-value-parser');
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function canonical(obj) {
return function recurse(key) {
if ((0, _has2.default)(obj, key) && obj[key] !== key) {
return recurse(obj[key]);
}
return key;
};
}
// Prevent potential infinite loops
let stack = 50;
return function recurse(key) {
if ((0, _has.default)(obj, key) && obj[key] !== key && stack) {
stack--;
return recurse(obj[key]);
}
function sameParent(ruleA, ruleB) {
var hasParent = ruleA.parent && ruleB.parent;
var sameType = hasParent && ruleA.parent.type === ruleB.parent.type;
// If an at rule, ensure that the parameters are the same
if (hasParent && ruleA.parent.type !== 'root' && ruleB.parent.type !== 'root') {
sameType = sameType && ruleA.parent.params === ruleB.parent.params && ruleA.parent.name === ruleB.parent.name;
}
return hasParent ? sameType : true;
stack = 50;
return key;
};
}
function mergeAtRules(css, pairs) {
pairs.forEach(function (pair) {
pair.cache = [];
pair.replacements = [];
pair.decls = [];
});
pairs.forEach(pair => {
pair.cache = [];
pair.replacements = [];
pair.decls = [];
pair.removals = [];
});
let relevant;
css.walk(node => {
if (node.type === 'atrule') {
relevant = pairs.filter(pair => pair.atrule.test(node.name.toLowerCase()))[0];
var relevant = void 0;
if (!relevant) {
return;
}
css.walk(function (node) {
if (node.type === 'atrule') {
relevant = pairs.filter(function (pair) {
return pair.atrule.test(node.name);
})[0];
if (!relevant) {
return;
}
if (relevant.cache.length < 1) {
relevant.cache.push(node);
return;
} else {
var _ret = function () {
var toString = node.nodes.toString();
relevant.cache.forEach(function (cached) {
if (cached.name === node.name && sameParent(cached, node) && cached.nodes.toString() === toString) {
cached.remove();
relevant.replacements[cached.params] = node.params;
}
});
relevant.cache.push(node);
return {
v: void 0
};
}();
if (relevant.cache.length < 1) {
relevant.cache.push(node);
return;
} else {
let toString = node.nodes.toString();
relevant.cache.forEach(cached => {
if (cached.name.toLowerCase() === node.name.toLowerCase() && (0, _cssnanoUtils.sameParent)(cached, node) && cached.nodes.toString() === toString) {
relevant.removals.push(cached);
relevant.replacements[cached.params] = node.params;
}
});
relevant.cache.push(node);
return;
}
}
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
}
if (node.type === 'decl') {
relevant = pairs.filter(pair => pair.decl.test(node.prop.toLowerCase()))[0];
if (!relevant) {
return;
}
relevant.decls.push(node);
}
});
pairs.forEach(pair => {
let canon = canonical(pair.replacements);
pair.decls.forEach(decl => {
decl.value = (0, _postcssValueParser.default)(decl.value).walk(node => {
if (node.type === 'word') {
node.value = canon(node.value);
}
if (node.type === 'decl') {
relevant = pairs.filter(function (pair) {
return pair.decl.test(node.prop);
})[0];
if (!relevant) {
return;
}
relevant.decls.push(node);
}
}).toString();
});
pairs.forEach(function (pair) {
var canon = canonical(pair.replacements);
pair.decls.forEach(function (decl) {
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
if (node.type === 'word') {
node.value = canon(node.value);
}
if (node.type === 'space') {
node.value = ' ';
}
if (node.type === 'div') {
node.before = node.after = '';
}
}).toString();
});
});
pair.removals.forEach(cached => cached.remove());
});
}
exports.default = (0, _postcss.plugin)('postcss-merge-idents', function () {
return function (css) {
mergeAtRules(css, [{
atrule: /keyframes/,
decl: /animation/
}, {
atrule: /counter-style/,
decl: /(list-style|system)/
}]);
};
var _default = (0, _postcss.plugin)('postcss-merge-idents', () => {
return css => {
mergeAtRules(css, [{
atrule: /keyframes/i,
decl: /animation/i
}, {
atrule: /counter-style/i,
decl: /(list-style|system)/i
}]);
};
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-merge-idents",
"version": "2.1.7",
"version": "4.0.0-nightly.2020.1.9",
"description": "Merge keyframe and counter style identifiers.",

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

"scripts": {
"pretest": "eslint src",
"prepublish": "del-cli dist && BABEL_ENV=publish 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": ""
},

@@ -24,18 +23,3 @@ "keywords": [

"license": "MIT",
"devDependencies": {
"ava": "^0.16.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.3.13",
"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": "^1.10.2"
},
"homepage": "https://github.com/ben-eb/postcss-merge-idents",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -46,14 +30,15 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/postcss-merge-idents",
"repository": "cssnano/cssnano",
"dependencies": {
"has": "^1.0.1",
"postcss": "^5.0.10",
"postcss-value-parser": "^3.1.1"
"cssnano-utils": "nightly",
"has": "^1.0.3",
"postcss": "^7.0.16",
"postcss-value-parser": "^3.3.1"
},
"ava": {
"require": "babel-register"
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"eslintConfig": {
"extends": "cssnano"
"engines": {
"node": ">=10.13.0"
}
}
}

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

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

@@ -67,6 +67,5 @@ > Merge keyframe and counter style identifiers.

## Contributing
## Contributors
Pull requests are welcome. If you add functionality, then please add unit tests
to cover it.
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).

@@ -79,5 +78,2 @@

[ci]: https://travis-ci.org/ben-eb/postcss-merge-idents
[deps]: https://gemnasium.com/ben-eb/postcss-merge-idents
[npm]: http://badge.fury.io/js/postcss-merge-idents
[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