a zip code crypto-currency system good for red ONLY

is-component-of.js 681B

1234567891011121314151617181920212223
  1. var compactable = require('../compactable');
  2. function isComponentOf(property1, property2, shallow) {
  3. return isDirectComponentOf(property1, property2) ||
  4. !shallow && !!compactable[property1.name].shorthandComponents && isSubComponentOf(property1, property2);
  5. }
  6. function isDirectComponentOf(property1, property2) {
  7. var descriptor = compactable[property1.name];
  8. return 'components' in descriptor && descriptor.components.indexOf(property2.name) > -1;
  9. }
  10. function isSubComponentOf(property1, property2) {
  11. return property1
  12. .components
  13. .some(function (component) {
  14. return isDirectComponentOf(component, property2);
  15. });
  16. }
  17. module.exports = isComponentOf;