reduce-css-calc

WebJar for reduce-css-calc

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

reduce-css-calc
Last Version

Last Version

2.1.8
Release Date

Release Date

Type

Type

jar
Description

Description

reduce-css-calc
WebJar for reduce-css-calc
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/MoOx/reduce-css-calc

Download reduce-css-calc

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/reduce-css-calc/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>reduce-css-calc</artifactId>
    <version>2.1.8</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/reduce-css-calc/
implementation 'org.webjars.npm:reduce-css-calc:2.1.8'
// https://jarcasting.com/artifacts/org.webjars.npm/reduce-css-calc/
implementation ("org.webjars.npm:reduce-css-calc:2.1.8")
'org.webjars.npm:reduce-css-calc:jar:2.1.8'
<dependency org="org.webjars.npm" name="reduce-css-calc" rev="2.1.8">
  <artifact name="reduce-css-calc" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='reduce-css-calc', version='2.1.8')
)
libraryDependencies += "org.webjars.npm" % "reduce-css-calc" % "2.1.8"
[org.webjars.npm/reduce-css-calc "2.1.8"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : css-unit-converter jar [1.1.1,2)
org.webjars.npm : postcss-value-parser jar [3.3.0,4)

Project Modules

There are no modules declared in this project.

reduce-css-calc

Build Status

Reduce CSS calc() function to the maximum.

Particularly useful for packages like rework-calc or postcss-calc.

Installation

npm install reduce-css-calc

Usage

var reducedString = reduceCSSCalc(string, precision)

var reduceCSSCalc = require('reduce-css-calc')

reduceCSSCalc("calc(1 + 1)")
// 2

reduceCSSCalc("calc((6 / 2) - (4 * 2) + 1)")
// -4

reduceCSSCalc("calc(1/3)")
// 0.33333

reduceCSSCalc("calc(1/3)", 10)
// 0.3333333333

reduceCSSCalc("calc(3rem * 2 - 1rem)")
// 5rem

reduceCSSCalc("calc(2 * 50%)")
// 100%

reduceCSSCalc("calc(120% * 50%)")
// 60%

reduceCSSCalc("a calc(1 + 1) b calc(1 - 1) c")
// a 2 b 0 c

reduceCSSCalc("calc(calc(calc(1rem * 0.75) * 1.5) - 1rem)")
// 0.125rem

reduceCSSCalc("calc(calc(calc(1rem * 0.75) * 1.5) - 1px)")
// calc(1.125rem - 1px)

reduceCSSCalc("-moz-calc(100px / 2)")
// 50px

reduceCSSCalc("-moz-calc(50% - 2em)")
// -moz-calc(50% - 2em)

See unit tests for others examples.


Contributing

Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.

git clone https://github.com/MoOx/reduce-css-calc.git
git checkout -b patch-1
npm install
npm test

Changelog

License

Versions

Version
2.1.8
2.1.7
2.1.6
2.1.4
2.0.0
1.3.0