@omegup/msync 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1763,9 +1763,8 @@ const loop = async (db) => {
1763
1763
  const m = watchers.get(doc.ns);
1764
1764
  if (!m)
1765
1765
  continue;
1766
- for (const { cb, keys, rem } of [...m.values()]) {
1767
- if (!keys ||
1768
- (doc.op === 'i' ? keys.p.every(k => fields.has(k)) : keys.k.some(k => fields.has(k)))) {
1766
+ for (const { cb, keys, rem, match } of [...m.values()]) {
1767
+ if (!keys || (doc.op === 'i' ? (match ? true : true) : keys.some(k => fields.has(k)))) {
1769
1768
  cb(doc);
1770
1769
  rem();
1771
1770
  }
@@ -1773,7 +1772,7 @@ const loop = async (db) => {
1773
1772
  }
1774
1773
  }
1775
1774
  };
1776
- const register = (coll, keys, cb) => {
1775
+ const register = (coll, keys, match, cb) => {
1777
1776
  const ns = coll.namespace;
1778
1777
  let m = watchers.get(ns);
1779
1778
  if (!m)
@@ -1784,7 +1783,7 @@ const register = (coll, keys, cb) => {
1784
1783
  if (m.size === 0)
1785
1784
  watchers.delete(ns);
1786
1785
  };
1787
- m.set(id, { cb, keys: keys ? { k: keys, p: keys.filter(k => k !== 'deletedAt') } : null, rem });
1786
+ m.set(id, { cb, keys, match, rem });
1788
1787
  if (!running) {
1789
1788
  running = true;
1790
1789
  loop(coll.s.db);
@@ -1799,7 +1798,7 @@ const makeWatchStream = async ({ collection, projection: p, hardMatch: m }, stre
1799
1798
  .updateMany({ touchedAt: maxTimestamp }, [{ $set: { touchedAt: '$$CLUSTER_TIME' } }]))).then(() => { }));
1800
1799
  const projection = { ...(p ? mapExactToObject(p, v => v) : {}), deletedAt: 1 };
1801
1800
  let notify = makePromise();
1802
- register(collection, p ? Object.keys(projection) : null, doc => {
1801
+ register(collection, p ? Object.keys(projection) : null, m, doc => {
1803
1802
  log(streamName, 'change detected', doc);
1804
1803
  notify.resolve(doc);
1805
1804
  });
package/index.js CHANGED
@@ -1765,9 +1765,8 @@ const loop = async (db) => {
1765
1765
  const m = watchers.get(doc.ns);
1766
1766
  if (!m)
1767
1767
  continue;
1768
- for (const { cb, keys, rem } of [...m.values()]) {
1769
- if (!keys ||
1770
- (doc.op === 'i' ? keys.p.every(k => fields.has(k)) : keys.k.some(k => fields.has(k)))) {
1768
+ for (const { cb, keys, rem, match } of [...m.values()]) {
1769
+ if (!keys || (doc.op === 'i' ? (match ? true : true) : keys.some(k => fields.has(k)))) {
1771
1770
  cb(doc);
1772
1771
  rem();
1773
1772
  }
@@ -1775,7 +1774,7 @@ const loop = async (db) => {
1775
1774
  }
1776
1775
  }
1777
1776
  };
1778
- const register = (coll, keys, cb) => {
1777
+ const register = (coll, keys, match, cb) => {
1779
1778
  const ns = coll.namespace;
1780
1779
  let m = watchers.get(ns);
1781
1780
  if (!m)
@@ -1786,7 +1785,7 @@ const register = (coll, keys, cb) => {
1786
1785
  if (m.size === 0)
1787
1786
  watchers.delete(ns);
1788
1787
  };
1789
- m.set(id, { cb, keys: keys ? { k: keys, p: keys.filter(k => k !== 'deletedAt') } : null, rem });
1788
+ m.set(id, { cb, keys, match, rem });
1790
1789
  if (!running) {
1791
1790
  running = true;
1792
1791
  loop(coll.s.db);
@@ -1801,7 +1800,7 @@ const makeWatchStream = async ({ collection, projection: p, hardMatch: m }, stre
1801
1800
  .updateMany({ touchedAt: maxTimestamp }, [{ $set: { touchedAt: '$$CLUSTER_TIME' } }]))).then(() => { }));
1802
1801
  const projection = { ...(p ? mapExactToObject(p, v => v) : {}), deletedAt: 1 };
1803
1802
  let notify = makePromise();
1804
- register(collection, p ? Object.keys(projection) : null, doc => {
1803
+ register(collection, p ? Object.keys(projection) : null, m, doc => {
1805
1804
  log(streamName, 'change detected', doc);
1806
1805
  notify.resolve(doc);
1807
1806
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "index.esm.js",
4
4
  "typings": "index.d.ts",
5
5
  "name": "@omegup/msync",
6
- "version": "0.1.34",
6
+ "version": "0.1.35",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",