snapshot.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. class Snapshot {
  4. constructor(options) {
  5. const { id, docChanges, docs, msgType, type } = options;
  6. let cachedDocChanges;
  7. let cachedDocs;
  8. Object.defineProperties(this, {
  9. id: {
  10. get: () => id,
  11. enumerable: true
  12. },
  13. docChanges: {
  14. get: () => {
  15. if (!cachedDocChanges) {
  16. cachedDocChanges = JSON.parse(JSON.stringify(docChanges));
  17. }
  18. return cachedDocChanges;
  19. },
  20. enumerable: true
  21. },
  22. docs: {
  23. get: () => {
  24. if (!cachedDocs) {
  25. cachedDocs = JSON.parse(JSON.stringify(docs));
  26. }
  27. return cachedDocs;
  28. },
  29. enumerable: true
  30. },
  31. msgType: {
  32. get: () => msgType,
  33. enumerable: true
  34. },
  35. type: {
  36. get: () => type,
  37. enumerable: true
  38. }
  39. });
  40. }
  41. }
  42. exports.Snapshot = Snapshot;