a zip code crypto-currency system good for red ONLY

populate-components.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var compactable = require('../compactable');
  2. var InvalidPropertyError = require('../invalid-property-error');
  3. function populateComponents(properties, validator, warnings) {
  4. var component;
  5. var j, m;
  6. for (var i = properties.length - 1; i >= 0; i--) {
  7. var property = properties[i];
  8. var descriptor = compactable[property.name];
  9. if (descriptor && descriptor.shorthand) {
  10. property.shorthand = true;
  11. property.dirty = true;
  12. try {
  13. property.components = descriptor.breakUp(property, compactable, validator);
  14. if (descriptor.shorthandComponents) {
  15. for (j = 0, m = property.components.length; j < m; j++) {
  16. component = property.components[j];
  17. component.components = compactable[component.name].breakUp(component, compactable, validator);
  18. }
  19. }
  20. } catch (e) {
  21. if (e instanceof InvalidPropertyError) {
  22. property.components = []; // this will set property.unused to true below
  23. warnings.push(e.message);
  24. } else {
  25. throw e;
  26. }
  27. }
  28. if (property.components.length > 0)
  29. property.multiplex = property.components[0].multiplex;
  30. else
  31. property.unused = true;
  32. }
  33. }
  34. }
  35. module.exports = populateComponents;