Socket
Socket
Sign inDemoInstall

postcss-zindex

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-zindex - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

5

CHANGELOG.md

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

# 2.0.1
* Improved performance of the module by sorting/deduplicating values in one pass
instead of per-value (thanks to @pgilad).
# 2.0.0

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

8

index.js

@@ -14,9 +14,13 @@ 'use strict';

});
// Second pass; optimise
cache.optimizeValues();
// Second pass; optimize
nodes.forEach(function (decl) {
// Need to coerce to string so that the
// AST is updated correctly
decl.value = '' + cache.convert(decl.value);
var value = cache.getValue(decl.value);
decl.value = String(value);
});
};
});
'use strict';
var uniq = require('uniqs');
function LayerCache () {

@@ -10,6 +12,4 @@ if (!(this instanceof LayerCache)) {

function sortAscending (key) {
return function (a, b) {
return a[key] - b[key];
};
function sortAscending (a, b) {
return a - b;
}

@@ -19,3 +19,3 @@

return {
from: value.from,
from: value,
to: index + 1

@@ -25,21 +25,32 @@ };

LayerCache.prototype._filterValues = function (value) {
return this._values.filter(function (index) {
return index.from === parseInt(value, 10);
});
LayerCache.prototype._findValue = function (value) {
var length = this._values.length;
for (var i = 0; i < length; ++i) {
if (this._values[i].from === value) {
return this._values[i];
}
}
return false;
};
LayerCache.prototype._optimiseValues = function () {
this._values = this._values.sort(sortAscending('from')).map(mapValues);
LayerCache.prototype.optimizeValues = function () {
var values = uniq(this._values)
.sort(sortAscending)
.map(mapValues);
this._values = values;
};
LayerCache.prototype.addValue = function (value) {
if (!this._filterValues(value).length && value > 0) {
this._values.push({ from: parseInt(value, 10) });
this._optimiseValues();
var parsedValue = parseInt(value, 10);
// pass only valid values
if (!parsedValue || parsedValue < 0) {
return;
}
this._values.push(parsedValue);
};
LayerCache.prototype.convert = function (value) {
var match = this._filterValues(value)[0];
LayerCache.prototype.getValue = function (value) {
var parsedValue = parseInt(value, 10);
var match = this._findValue(parsedValue);
return match && match.to || value;

@@ -46,0 +57,0 @@ };

{
"name": "postcss-zindex",
"version": "2.0.0",
"version": "2.0.1",
"description": "Reduce z-index values with PostCSS.",

@@ -10,2 +10,7 @@ "main": "index.js",

},
"files": [
"LICENSE-MIT",
"index.js",
"lib"
],
"keywords": [

@@ -22,3 +27,4 @@ "css",

"dependencies": {
"postcss": "^5.0.4"
"postcss": "^5.0.4",
"uniqs": "^2.0.0"
},

@@ -25,0 +31,0 @@ "devDependencies": {

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