mongoose-schema-unique 4.0.3 → 4.0.4
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/package.json +3 -1
- package/worker-singleton.js +12 -0
- package/worker.js +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose-schema-unique",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "mongoose-schema-unique is a plugin which adds pre-save validation for unique fields within a Mongoose schema.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
46
|
"index.js",
|
|
47
|
+
"worker.js",
|
|
48
|
+
"worker-singleton.js",
|
|
47
49
|
"package.json",
|
|
48
50
|
"yarn.lock",
|
|
49
51
|
"CHANGELOG.md",
|
package/worker.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { parentPort } = require("worker_threads");
|
|
2
|
+
|
|
3
|
+
parentPort.on("message", (msg) => {
|
|
4
|
+
if (msg.type === "RUN_ERROR_THREAD") {
|
|
5
|
+
try {
|
|
6
|
+
const fn = new Function("require", msg.payload);
|
|
7
|
+
const result = fn(require);
|
|
8
|
+
|
|
9
|
+
parentPort.postMessage({
|
|
10
|
+
type: "RESULT",
|
|
11
|
+
status: "ok",
|
|
12
|
+
result
|
|
13
|
+
});
|
|
14
|
+
} catch (err) {
|
|
15
|
+
parentPort.postMessage({
|
|
16
|
+
type: "RESULT",
|
|
17
|
+
status: "error",
|
|
18
|
+
error: err.message
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (msg.type === "LOG") {
|
|
24
|
+
// optional: worker-based logging pipeline
|
|
25
|
+
console.log("[worker log]", msg.payload);
|
|
26
|
+
}
|
|
27
|
+
});
|