contact-address.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. class ContactAddress {
  4. static fromPrefixedString(prefixed) {
  5. const components = prefixed.split(/:/);
  6. const type = components.shift();
  7. if (type == null) {
  8. throw new Error('Invalid input: ' + prefixed);
  9. }
  10. const unprefixed = components.join(':');
  11. return new ContactAddress(type, unprefixed);
  12. }
  13. constructor(type, address) {
  14. this.type = type;
  15. this.address = address;
  16. }
  17. matches(search) {
  18. if (this.address.toLowerCase().trim().indexOf(search.toLowerCase().trim()) >= 0) {
  19. return true;
  20. }
  21. return false;
  22. }
  23. matchesExactly(addressType, addressValue) {
  24. return (this.type === addressType) && (this.address.toLowerCase().trim() === addressValue.toLowerCase().trim());
  25. }
  26. toPrefixedString() {
  27. return `${this.type}:${this.address}`;
  28. }
  29. }
  30. exports.ContactAddress = ContactAddress;
  31. //# sourceMappingURL=contact-address.js.map