You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
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;
|