@omegup/msync 0.0.33 → 0.0.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.
Files changed (3) hide show
  1. package/index.esm.js +11 -9
  2. package/index.js +11 -9
  3. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1168,7 +1168,7 @@ const addTeardown = (it, tr) => {
1168
1168
  next: n.then(({ cont, ...res }) => ({ cont: addTeardown(cont, tr), ...res })),
1169
1169
  stop: () => (tr(), stop()),
1170
1170
  clear: async () => {
1171
- tr();
1171
+ await tr();
1172
1172
  await clear();
1173
1173
  },
1174
1174
  };
@@ -1184,7 +1184,12 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1184
1184
  const q = $or(...changeKeys.map((k) => subQ(m, root().of(k))));
1185
1185
  if (q)
1186
1186
  pipeline.push({
1187
- $match: { $or: [q.raw(root()), Object.fromEntries(changeKeys.map(k => [k, null]))] },
1187
+ $match: {
1188
+ $or: [
1189
+ q.raw(root()),
1190
+ Object.fromEntries(changeKeys.map(k => [k, null])),
1191
+ ],
1192
+ },
1188
1193
  });
1189
1194
  }
1190
1195
  pipeline.push({
@@ -1266,11 +1271,12 @@ const executes$1 = (view, input, streamName) => {
1266
1271
  const withStop = (next, tr) => {
1267
1272
  return addTeardown(() => ({ stop, next: next(), clear }), tr);
1268
1273
  };
1269
- const next = (next, debug, tr) => ({
1274
+ const nextData = (data, job) => (next, debug, tr) => ({
1270
1275
  cont: withStop(next, tr),
1271
- data: [],
1276
+ data,
1272
1277
  info: { job, debug: `${streamName} on ${collection.collectionName}: ${debug}` },
1273
1278
  });
1279
+ const next = nextData([], job);
1274
1280
  const data = {
1275
1281
  input: input.delta,
1276
1282
  finalInputFirst: finalInput.raw(true),
@@ -1384,11 +1390,7 @@ const executes$1 = (view, input, streamName) => {
1384
1390
  return step8(l);
1385
1391
  };
1386
1392
  const step8 = (l) => {
1387
- return {
1388
- data: l.aggResult.cursor.firstBatch,
1389
- info: { job: undefined, debug: 'wait for change' },
1390
- cont: withStop(() => l.stream.tryNext().then(doc => (doc ? next(step2, 'restart') : step8(l)))),
1391
- };
1393
+ return nextData(l.aggResult.cursor.firstBatch)(() => l.stream.tryNext().then(doc => (doc ? next(step2, 'restart') : step8(l))), 'wait for change');
1392
1394
  };
1393
1395
  return stop;
1394
1396
  };
package/index.js CHANGED
@@ -1170,7 +1170,7 @@ const addTeardown = (it, tr) => {
1170
1170
  next: n.then(({ cont, ...res }) => ({ cont: addTeardown(cont, tr), ...res })),
1171
1171
  stop: () => (tr(), stop()),
1172
1172
  clear: async () => {
1173
- tr();
1173
+ await tr();
1174
1174
  await clear();
1175
1175
  },
1176
1176
  };
@@ -1186,7 +1186,12 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1186
1186
  const q = $or(...changeKeys.map((k) => subQ(m, root().of(k))));
1187
1187
  if (q)
1188
1188
  pipeline.push({
1189
- $match: { $or: [q.raw(root()), Object.fromEntries(changeKeys.map(k => [k, null]))] },
1189
+ $match: {
1190
+ $or: [
1191
+ q.raw(root()),
1192
+ Object.fromEntries(changeKeys.map(k => [k, null])),
1193
+ ],
1194
+ },
1190
1195
  });
1191
1196
  }
1192
1197
  pipeline.push({
@@ -1268,11 +1273,12 @@ const executes$1 = (view, input, streamName) => {
1268
1273
  const withStop = (next, tr) => {
1269
1274
  return addTeardown(() => ({ stop, next: next(), clear }), tr);
1270
1275
  };
1271
- const next = (next, debug, tr) => ({
1276
+ const nextData = (data, job) => (next, debug, tr) => ({
1272
1277
  cont: withStop(next, tr),
1273
- data: [],
1278
+ data,
1274
1279
  info: { job, debug: `${streamName} on ${collection.collectionName}: ${debug}` },
1275
1280
  });
1281
+ const next = nextData([], job);
1276
1282
  const data = {
1277
1283
  input: input.delta,
1278
1284
  finalInputFirst: finalInput.raw(true),
@@ -1386,11 +1392,7 @@ const executes$1 = (view, input, streamName) => {
1386
1392
  return step8(l);
1387
1393
  };
1388
1394
  const step8 = (l) => {
1389
- return {
1390
- data: l.aggResult.cursor.firstBatch,
1391
- info: { job: undefined, debug: 'wait for change' },
1392
- cont: withStop(() => l.stream.tryNext().then(doc => (doc ? next(step2, 'restart') : step8(l)))),
1393
- };
1395
+ return nextData(l.aggResult.cursor.firstBatch)(() => l.stream.tryNext().then(doc => (doc ? next(step2, 'restart') : step8(l))), 'wait for change');
1394
1396
  };
1395
1397
  return stop;
1396
1398
  };
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.0.33",
6
+ "version": "0.0.35",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",