summaryrefslogtreecommitdiff
path: root/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js')
-rw-r--r--node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js b/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js
new file mode 100644
index 00000000..8fb2021c
--- /dev/null
+++ b/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js
@@ -0,0 +1,31 @@
+var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
+
+var TIME_VALUE = /^(-?[\d.]+)(m?s)$/;
+
+var plugin = {
+ level1: {
+ value: function time(name, value, options) {
+ if (!options.level[OptimizationLevel.One].replaceTimeUnits) {
+ return value;
+ }
+
+ if (!TIME_VALUE.test(value)) {
+ return value;
+ }
+
+ return value.replace(TIME_VALUE, function(match, val, unit) {
+ var newValue;
+
+ if (unit == 'ms') {
+ newValue = parseInt(val) / 1000 + 's';
+ } else if (unit == 's') {
+ newValue = parseFloat(val) * 1000 + 'ms';
+ }
+
+ return newValue.length < match.length ? newValue : match;
+ });
+ }
+ }
+};
+
+module.exports = plugin;