The precision plugin normalizes decimal number precision.
It will automatically round up values.
yarn add bredon-plugin-precision
You may alternatively use npm i --save bredon-plugin-precision
.
import { compile } from 'bredon'
import precisionPlugin from 'bredon-plugin-precision'
const input = '33.3333333% solid rgba(10, 10, 10, 0.564)'
const output = compile(input, {
plugins: [
precisionPlugin()
]
})
console.log(output)
// => 33.3333% solid rgba(10, 10, 10, 0.564)
By default, the precision is set to 4
.
Options | Value | Default | Description |
---|---|---|---|
precision | number | 4 | The prefered precision |
import { compile } from 'bredon'
import precisionPlugin from 'bredon-plugin-precision'
const input = '33.3333333% solid rgba(10, 10, 10, 0.564)'
const output = compile(input, {
plugins: [
precisionPlugin({
precision: 2
})
]
})
console.log(output)
// => 33.3% solid rgba(10, 10, 10, 0.56)
Bredon is licensed under the MIT License.
Documentation is licensed under Creative Common License.
Created with ♥ by @rofrischmann and all the great contributors.