UNPKG

@xmtp/content-type-primitives

Version:

Primitives for building custom XMTP content types

33 lines (31 loc) 982 B
class ContentTypeId { authorityId; typeId; versionMajor; versionMinor; constructor(obj) { this.authorityId = obj.authorityId; this.typeId = obj.typeId; this.versionMajor = obj.versionMajor; this.versionMinor = obj.versionMinor; } toString() { return `${this.authorityId}/${this.typeId}:${this.versionMajor}.${this.versionMinor}`; } static fromString(contentTypeString) { const [idString, versionString] = contentTypeString.split(":"); const [authorityId, typeId] = idString.split("/"); const [major, minor] = versionString.split("."); return new ContentTypeId({ authorityId, typeId, versionMajor: Number(major), versionMinor: Number(minor), }); } sameAs(id) { return this.authorityId === id.authorityId && this.typeId === id.typeId; } } export { ContentTypeId }; //# sourceMappingURL=index.js.map