Id.js 2.1 KB

1234567891011121314151617181920
  1. "use strict";
  2. class Id {
  3. constructor(className, objectId) {
  4. this.className = className;
  5. this.objectId = objectId;
  6. }
  7. toString() {
  8. return this.className + ':' + this.objectId;
  9. }
  10. static fromString(str) {
  11. var split = str.split(':');
  12. if (split.length !== 2) {
  13. throw new TypeError('Cannot create Id object from this string');
  14. }
  15. return new Id(split[0], split[1]);
  16. }
  17. }
  18. module.exports = Id;
  19. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJJZCIsImNvbnN0cnVjdG9yIiwiY2xhc3NOYW1lIiwib2JqZWN0SWQiLCJ0b1N0cmluZyIsImZyb21TdHJpbmciLCJzdHIiLCJzcGxpdCIsImxlbmd0aCIsIlR5cGVFcnJvciIsIm1vZHVsZSIsImV4cG9ydHMiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvTGl2ZVF1ZXJ5L0lkLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImNsYXNzIElkIHtcbiAgY2xhc3NOYW1lOiBzdHJpbmc7XG4gIG9iamVjdElkOiBzdHJpbmc7XG5cbiAgY29uc3RydWN0b3IoY2xhc3NOYW1lOiBzdHJpbmcsIG9iamVjdElkOiBzdHJpbmcpIHtcbiAgICB0aGlzLmNsYXNzTmFtZSA9IGNsYXNzTmFtZTtcbiAgICB0aGlzLm9iamVjdElkID0gb2JqZWN0SWQ7XG4gIH1cbiAgdG9TdHJpbmcoKTogc3RyaW5nIHtcbiAgICByZXR1cm4gdGhpcy5jbGFzc05hbWUgKyAnOicgKyB0aGlzLm9iamVjdElkO1xuICB9XG5cbiAgc3RhdGljIGZyb21TdHJpbmcoc3RyOiBzdHJpbmcpIHtcbiAgICB2YXIgc3BsaXQgPSBzdHIuc3BsaXQoJzonKTtcbiAgICBpZiAoc3BsaXQubGVuZ3RoICE9PSAyKSB7XG4gICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdDYW5ub3QgY3JlYXRlIEl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