worker-testbed 1.0.6 → 1.0.7

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/build/index.cjs CHANGED
@@ -67,7 +67,7 @@ const test = async (testName, cb) => {
67
67
  }
68
68
  });
69
69
  };
70
- const run = async (__filename, cb = () => { }) => {
70
+ const run = functoolsKit.singleshot(async (__filename, cb = () => { }) => {
71
71
  if (worker_threads.isMainThread) {
72
72
  await workerFileSubject.next(url.fileURLToPath(__filename));
73
73
  await finishSubject.filter(() => testCounter === 0).toPromise();
@@ -81,7 +81,7 @@ const run = async (__filename, cb = () => { }) => {
81
81
  pass: (msg) => worker_threads.parentPort.postMessage({ status: "pass", msg }),
82
82
  fail: (msg) => worker_threads.parentPort.postMessage({ status: "fail", msg }),
83
83
  });
84
- };
84
+ });
85
85
 
86
86
  exports.run = run;
87
87
  exports.test = test;
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { isMainThread, Worker, parentPort, workerData } from 'worker_threads';
1
+ import { isMainThread, parentPort, workerData, Worker } from 'worker_threads';
2
2
  import { fileURLToPath } from 'url';
3
- import { BehaviorSubject, Subject, ToolRegistry, createAwaiter } from 'functools-kit';
3
+ import { BehaviorSubject, Subject, ToolRegistry, singleshot, createAwaiter } from 'functools-kit';
4
4
  import tape from 'tape';
5
5
 
6
6
  const workerFileSubject = new BehaviorSubject();
@@ -65,7 +65,7 @@ const test = async (testName, cb) => {
65
65
  }
66
66
  });
67
67
  };
68
- const run = async (__filename, cb = () => { }) => {
68
+ const run = singleshot(async (__filename, cb = () => { }) => {
69
69
  if (isMainThread) {
70
70
  await workerFileSubject.next(fileURLToPath(__filename));
71
71
  await finishSubject.filter(() => testCounter === 0).toPromise();
@@ -79,6 +79,6 @@ const run = async (__filename, cb = () => { }) => {
79
79
  pass: (msg) => parentPort.postMessage({ status: "pass", msg }),
80
80
  fail: (msg) => parentPort.postMessage({ status: "fail", msg }),
81
81
  });
82
- };
82
+ });
83
83
 
84
84
  export { run, test };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worker-testbed",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "The AI-ready testbed which use Worker Threads to create isolated vm context",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import * as functools_kit from 'functools-kit';
2
+
1
3
  interface ITest {
2
4
  pass(msg?: string): void;
3
5
  fail(msg?: string): void;
4
6
  }
5
7
  declare const test: (testName: string, cb: (t: ITest) => void) => Promise<void>;
6
- declare const run: (__filename: string, cb?: () => void) => Promise<void>;
8
+ declare const run: ((__filename: string, cb?: () => void) => Promise<void>) & functools_kit.ISingleshotClearable;
7
9
 
8
10
  export { run, test };