Opal-Estate-Pro/node_modules/csso/lib/compressor/compress/Number.js
2019-09-13 11:27:52 +07:00

23 lines
493 B
JavaScript
Executable File

function packNumber(value) {
// 100 -> '100'
// 00100 -> '100'
// +100 -> '100'
// -100 -> '-100'
// 0.123 -> '.123'
// 0.12300 -> '.123'
// 0.0 -> ''
// 0 -> ''
value = String(value).replace(/^(?:\+|(-))?0*(\d*)(?:\.0*|(\.\d*?)0*)?$/, '$1$2$3');
if (value.length === 0 || value === '-') {
value = '0';
}
return value;
};
module.exports = function(node) {
node.value = packNumber(node.value);
};
module.exports.pack = packNumber;