@omegup/msync 0.0.40 → 0.0.41
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 +12 -2
- package/index.js +12 -2
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UUID, MongoClient } from 'mongodb';
|
|
2
2
|
import { SynchronousPromise } from 'synchronous-promise';
|
|
3
3
|
import crypto$1 from 'crypto';
|
|
4
|
+
import { log as log$1 } from 'console';
|
|
4
5
|
import { writeFile } from 'fs/promises';
|
|
5
6
|
|
|
6
7
|
const asExprRaw = (raw) => ({ get: () => raw });
|
|
@@ -1132,8 +1133,15 @@ const restart = (sources) => {
|
|
|
1132
1133
|
return map(sources, x => x.stop());
|
|
1133
1134
|
};
|
|
1134
1135
|
const race = (sources) => {
|
|
1135
|
-
const promises = Object.values(map(sources, ({ next }, key) => next.then(frame => ({ key,
|
|
1136
|
-
return SynchronousPromise.any(promises)
|
|
1136
|
+
const promises = Object.values(map(sources, ({ next }, key) => next.then(frame => ({ key, frame }), error => new Error(error))));
|
|
1137
|
+
return SynchronousPromise.any(promises).then((result) => {
|
|
1138
|
+
if (result instanceof Error) {
|
|
1139
|
+
throw result;
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
return result;
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1137
1145
|
};
|
|
1138
1146
|
|
|
1139
1147
|
const nextWinner = (previousWinner, previousWinnerNextFrame, sources, interrupt) => {
|
|
@@ -1452,6 +1460,8 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
|
|
|
1452
1460
|
const doc = await stream.tryNext();
|
|
1453
1461
|
if (doc)
|
|
1454
1462
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
1463
|
+
if (doc)
|
|
1464
|
+
log$1('detected', doc);
|
|
1455
1465
|
return doc;
|
|
1456
1466
|
};
|
|
1457
1467
|
return { tryNext, close: () => stream.close() };
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var mongodb = require('mongodb');
|
|
4
4
|
var synchronousPromise = require('synchronous-promise');
|
|
5
5
|
var crypto$1 = require('crypto');
|
|
6
|
+
var console$1 = require('console');
|
|
6
7
|
var promises = require('fs/promises');
|
|
7
8
|
|
|
8
9
|
const asExprRaw = (raw) => ({ get: () => raw });
|
|
@@ -1134,8 +1135,15 @@ const restart = (sources) => {
|
|
|
1134
1135
|
return map(sources, x => x.stop());
|
|
1135
1136
|
};
|
|
1136
1137
|
const race = (sources) => {
|
|
1137
|
-
const promises = Object.values(map(sources, ({ next }, key) => next.then(frame => ({ key,
|
|
1138
|
-
return synchronousPromise.SynchronousPromise.any(promises)
|
|
1138
|
+
const promises = Object.values(map(sources, ({ next }, key) => next.then(frame => ({ key, frame }), error => new Error(error))));
|
|
1139
|
+
return synchronousPromise.SynchronousPromise.any(promises).then((result) => {
|
|
1140
|
+
if (result instanceof Error) {
|
|
1141
|
+
throw result;
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
return result;
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1139
1147
|
};
|
|
1140
1148
|
|
|
1141
1149
|
const nextWinner = (previousWinner, previousWinnerNextFrame, sources, interrupt) => {
|
|
@@ -1454,6 +1462,8 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
|
|
|
1454
1462
|
const doc = await stream.tryNext();
|
|
1455
1463
|
if (doc)
|
|
1456
1464
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
1465
|
+
if (doc)
|
|
1466
|
+
console$1.log('detected', doc);
|
|
1457
1467
|
return doc;
|
|
1458
1468
|
};
|
|
1459
1469
|
return { tryNext, close: () => stream.close() };
|