🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

reduce-css-calc

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reduce-css-calc - npm Package Compare versions

Comparing version

to
2.1.2

4

CHANGELOG.md

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

# 2.1.2 - 2017-11-26
- Fixed: Incorrect reduction of division with custom property (e.g. `calc(var(--foo) / 2)`) ([#41](https://github.com/MoOx/reduce-css-calc/issues/41) - @Semigradsky)
# 2.1.1 - 2017-10-12

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

30

dist/index.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

@@ -27,22 +27,22 @@

exports.default = function (value) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
return (0, _postcssValueParser2.default)(value).walk(function (node) {
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;
return (0, _postcssValueParser2.default)(value).walk(function (node) {
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;
// stringify calc expression and produce an AST
var contents = _postcssValueParser2.default.stringify(node.nodes);
var ast = _parser.parser.parse(contents);
// stringify calc expression and produce an AST
var contents = _postcssValueParser2.default.stringify(node.nodes);
var ast = _parser.parser.parse(contents);
// reduce AST to its simplest form, that is, either to a single value
// or a simplified calc expression
var reducedAst = (0, _reducer2.default)(ast, precision);
// reduce AST to its simplest form, that is, either to a single value
// or a simplified calc expression
var reducedAst = (0, _reducer2.default)(ast, precision);
// stringify AST and write it back
node.type = 'word';
node.value = (0, _stringifier2.default)(node.value, reducedAst, precision);
}, true).toString();
// stringify AST and write it back
node.type = 'word';
node.value = (0, _stringifier2.default)(node.value, reducedAst, precision);
}, true).toString();
};
module.exports = exports['default'];

@@ -207,6 +207,8 @@ 'use strict';

}
// value / value
node.left.value /= node.right.value;
return node.left;
// something / value
else if (isValueType(node.left.type)) {
node.left.value /= node.right.value;
return node.left;
}
return node;
}

@@ -213,0 +215,0 @@

{
"name": "reduce-css-calc",
"version": "2.1.1",
"version": "2.1.2",
"description": "Reduce CSS calc() function to the maximum",

@@ -5,0 +5,0 @@ "keywords": [

@@ -0,0 +0,0 @@ # reduce-css-calc [![Build Status](https://travis-ci.org/MoOx/reduce-css-calc.png)](https://travis-ci.org/MoOx/reduce-css-calc)

Sorry, the diff of this file is not supported yet