minifyWsc.js
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _parseWsc = require('./parseWsc');
var _parseWsc2 = _interopRequireDefault(_parseWsc);
var _minifyTrbl = require('./minifyTrbl');
var _minifyTrbl2 = _interopRequireDefault(_minifyTrbl);
var _validateWsc = require('./validateWsc');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const defaults = ['medium', 'none', 'currentcolor'];
exports.default = v => {
const values = (0, _parseWsc2.default)(v);
if (!(0, _validateWsc.isValidWsc)(values)) {
return (0, _minifyTrbl2.default)(v);
}
const value = [...values, ''].reduceRight((prev, cur, i, arr) => {
if (cur === undefined || cur.toLowerCase() === defaults[i] && (!i || (arr[i - 1] || '').toLowerCase() !== cur.toLowerCase())) {
return prev;
}
return cur + ' ' + prev;
}).trim();
return (0, _minifyTrbl2.default)(value || 'none');
};
module.exports = exports['default'];