a zip code crypto-currency system good for red ONLY

optimize.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var mergeIntoShorthands = require('./merge-into-shorthands');
  2. var overrideProperties = require('./override-properties');
  3. var populateComponents = require('./populate-components');
  4. var restoreWithComponents = require('../restore-with-components');
  5. var wrapForOptimizing = require('../../wrap-for-optimizing').all;
  6. var removeUnused = require('../../remove-unused');
  7. var restoreFromOptimizing = require('../../restore-from-optimizing');
  8. var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
  9. function optimizeProperties(properties, withOverriding, withMerging, context) {
  10. var levelOptions = context.options.level[OptimizationLevel.Two];
  11. var _properties = wrapForOptimizing(properties, false, levelOptions.skipProperties);
  12. var _property;
  13. var i, l;
  14. populateComponents(_properties, context.validator, context.warnings);
  15. for (i = 0, l = _properties.length; i < l; i++) {
  16. _property = _properties[i];
  17. if (_property.block) {
  18. optimizeProperties(_property.value[0][1], withOverriding, withMerging, context);
  19. }
  20. }
  21. if (withMerging && levelOptions.mergeIntoShorthands) {
  22. mergeIntoShorthands(_properties, context.validator);
  23. }
  24. if (withOverriding && levelOptions.overrideProperties) {
  25. overrideProperties(_properties, withMerging, context.options.compatibility, context.validator);
  26. }
  27. restoreFromOptimizing(_properties, restoreWithComponents);
  28. removeUnused(_properties);
  29. }
  30. module.exports = optimizeProperties;