minifyWsc.js 1.0 KB

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