source: imaps-frontend/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 753 bytes
Line 
1var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
2
3var TIME_VALUE = /^(-?[\d.]+)(m?s)$/;
4
5var plugin = {
6 level1: {
7 value: function time(name, value, options) {
8 if (!options.level[OptimizationLevel.One].replaceTimeUnits) {
9 return value;
10 }
11
12 if (!TIME_VALUE.test(value)) {
13 return value;
14 }
15
16 return value.replace(TIME_VALUE, function(match, val, unit) {
17 var newValue;
18
19 if (unit == 'ms') {
20 newValue = parseInt(val) / 1000 + 's';
21 } else if (unit == 's') {
22 newValue = parseFloat(val) * 1000 + 'ms';
23 }
24
25 return newValue.length < match.length ? newValue : match;
26 });
27 }
28 }
29};
30
31module.exports = plugin;
Note: See TracBrowser for help on using the repository browser.