main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
753 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
|
---|
| 2 |
|
---|
| 3 | var TIME_VALUE = /^(-?[\d.]+)(m?s)$/;
|
---|
| 4 |
|
---|
| 5 | var 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 |
|
---|
| 31 | module.exports = plugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.