synckit 0.4.1 → 0.5.0
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/CHANGELOG.md +3 -3
- package/README.md +4 -10
- package/lib/index.cjs +21 -104
- package/lib/index.d.ts +1 -6
- package/lib/index.js +22 -97
- package/lib/index.js.map +1 -1
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# synckit
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.5.0
|
4
4
|
|
5
|
-
###
|
5
|
+
### Minor Changes
|
6
6
|
|
7
|
-
- [`
|
7
|
+
- [#47](https://github.com/rx-ts/synckit/pull/47) [`a362982`](https://github.com/rx-ts/synckit/commit/a362982eac4083ff3d00b4f6a9d4f4183dd2418e) Thanks [@JounQin](https://github.com/JounQin)! - feat: drop child_process
|
8
8
|
|
9
9
|
## 0.4.0
|
10
10
|
|
package/README.md
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
[](https://standardjs.com)
|
17
17
|
[](https://github.com/prettier/prettier)
|
18
18
|
|
19
|
-
Perform async work synchronously in Node.js using `worker_threads
|
19
|
+
Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.
|
20
20
|
|
21
21
|
## TOC <!-- omit in toc -->
|
22
22
|
|
@@ -43,8 +43,6 @@ npm i synckit
|
|
43
43
|
|
44
44
|
### API
|
45
45
|
|
46
|
-
`worker_threads` is used by default for performance, if you have any problem with it, you can set env `SYNCKIT_WORKER_THREADS=0` to disable it and fallback to previously `child_process` solution, and please raise an issue here so that we can improve it.
|
47
|
-
|
48
46
|
```js
|
49
47
|
// runner.js
|
50
48
|
import { createSyncFn } from 'synckit'
|
@@ -66,16 +64,12 @@ runAsWorker(async (...args) => {
|
|
66
64
|
})
|
67
65
|
```
|
68
66
|
|
69
|
-
You must make sure
|
70
|
-
|
71
|
-
1. if `worker_threads` is enabled (by default), the `result` is serialized by [`Structured Clone Algorithm`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
|
72
|
-
2. if `child_process` is used, the `result` is serialized by `JSON.stringify`
|
67
|
+
You must make sure, the `result` is serialized by [`Structured Clone Algorithm`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
|
73
68
|
|
74
69
|
### Envs
|
75
70
|
|
76
|
-
1. `
|
77
|
-
2. `
|
78
|
-
3. `SYNCKIT_TIMEOUT`: `timeout` for performing the async job (no default)
|
71
|
+
1. `SYNCKIT_BUFFER_SIZE`: `bufferSize` to create `SharedArrayBuffer` for `worker_threads` (default as `1024`)
|
72
|
+
2. `SYNCKIT_TIMEOUT`: `timeout` for performing the async job (no default)
|
79
73
|
|
80
74
|
### TypeScript
|
81
75
|
|
package/lib/index.cjs
CHANGED
@@ -2,37 +2,13 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var child_process = require('child_process');
|
6
|
-
var os = require('os');
|
7
5
|
var path = require('path');
|
8
|
-
var
|
9
|
-
var module$1 = require('module');
|
10
|
-
var uuid = require('uuid');
|
6
|
+
var worker_threads = require('worker_threads');
|
11
7
|
|
12
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
9
|
|
14
10
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
16
11
|
|
17
|
-
var __defProp = Object.defineProperty;
|
18
|
-
var __defProps = Object.defineProperties;
|
19
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
20
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
21
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
22
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
23
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
24
|
-
var __spreadValues = (a, b) => {
|
25
|
-
for (var prop in b || (b = {}))
|
26
|
-
if (__hasOwnProp.call(b, prop))
|
27
|
-
__defNormalProp(a, prop, b[prop]);
|
28
|
-
if (__getOwnPropSymbols)
|
29
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
30
|
-
if (__propIsEnum.call(b, prop))
|
31
|
-
__defNormalProp(a, prop, b[prop]);
|
32
|
-
}
|
33
|
-
return a;
|
34
|
-
};
|
35
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
36
12
|
var __async = (__this, __arguments, generator) => {
|
37
13
|
return new Promise((resolve, reject) => {
|
38
14
|
var fulfilled = (value) => {
|
@@ -53,27 +29,7 @@ var __async = (__this, __arguments, generator) => {
|
|
53
29
|
step((generator = generator.apply(__this, __arguments)).next());
|
54
30
|
});
|
55
31
|
};
|
56
|
-
const
|
57
|
-
const tmpdir = fs__default['default'].realpathSync(os.tmpdir());
|
58
|
-
let workerThreads;
|
59
|
-
const cjsRequire = typeof require === "undefined" ? module$1.createRequire(import_meta.url) : require;
|
60
|
-
try {
|
61
|
-
workerThreads = cjsRequire("worker_threads");
|
62
|
-
if (typeof workerThreads.receiveMessageOnPort !== "function") {
|
63
|
-
workerThreads = void 0;
|
64
|
-
}
|
65
|
-
} catch (e) {
|
66
|
-
}
|
67
|
-
if (!workerThreads) {
|
68
|
-
console.warn("[synckit]: `worker_threads` or `receiveMessageOnPort` is not available in current environment, `Node >= 12` is required");
|
69
|
-
}
|
70
|
-
const {
|
71
|
-
SYNCKIT_WORKER_THREADS,
|
72
|
-
SYNCKIT_BUFFER_SIZE,
|
73
|
-
SYNCKIT_TIMEOUT,
|
74
|
-
SYNCKIT_TS_ESM
|
75
|
-
} = process.env;
|
76
|
-
const useWorkerThreads = !!workerThreads && (!SYNCKIT_WORKER_THREADS || !["0", "false"].includes(SYNCKIT_WORKER_THREADS));
|
32
|
+
const { SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT, SYNCKIT_TS_ESM } = process.env;
|
77
33
|
const TS_USE_ESM = !!SYNCKIT_TS_ESM && ["1", "true"].includes(SYNCKIT_TS_ESM);
|
78
34
|
const DEFAULT_BUFFER_SIZE = SYNCKIT_BUFFER_SIZE ? +SYNCKIT_BUFFER_SIZE : void 0;
|
79
35
|
const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : void 0;
|
@@ -87,40 +43,17 @@ function createSyncFn(workerPath, bufferSize, timeout = DEFAULT_TIMEOUT) {
|
|
87
43
|
if (cachedSyncFn) {
|
88
44
|
return cachedSyncFn;
|
89
45
|
}
|
90
|
-
const syncFn =
|
46
|
+
const syncFn = startWorkerThread(workerPath, bufferSize, timeout);
|
91
47
|
syncFnCache.set(workerPath, syncFn);
|
92
48
|
return syncFn;
|
93
49
|
}
|
94
|
-
function startChildProcess(workerPath, bufferSize = DEFAULT_BUFFER_SIZE, timeout) {
|
95
|
-
const executor = workerPath.endsWith(".ts") ? TS_USE_ESM ? "node --loader ts-node/esm" : "ts-node" : "node";
|
96
|
-
return (...args) => {
|
97
|
-
const filename = path__default['default'].resolve(tmpdir, `synckit-${uuid.v4()}.json`);
|
98
|
-
fs__default['default'].writeFileSync(filename, JSON.stringify(args));
|
99
|
-
const command = `${executor} ${workerPath} ${filename}`;
|
100
|
-
try {
|
101
|
-
child_process.execSync(command, {
|
102
|
-
stdio: "inherit",
|
103
|
-
maxBuffer: bufferSize,
|
104
|
-
timeout
|
105
|
-
});
|
106
|
-
const { result, error } = JSON.parse(fs__default['default'].readFileSync(filename, "utf8"));
|
107
|
-
if (error) {
|
108
|
-
throw typeof error === "object" && "message" in error ? Object.assign(new Error(), error) : error;
|
109
|
-
}
|
110
|
-
return result;
|
111
|
-
} finally {
|
112
|
-
fs__default['default'].unlinkSync(filename);
|
113
|
-
}
|
114
|
-
};
|
115
|
-
}
|
116
50
|
const throwError = (msg) => {
|
117
51
|
throw new Error(msg);
|
118
52
|
};
|
119
53
|
function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE, timeout) {
|
120
|
-
const {
|
121
|
-
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
54
|
+
const { port1: mainPort, port2: workerPort } = new worker_threads.MessageChannel();
|
122
55
|
const isTs = workerPath.endsWith(".ts");
|
123
|
-
const worker = new Worker(isTs ? TS_USE_ESM ? throwError("Native esm in `.ts` file is not supported yet, please use `.cjs` instead") : `require('ts-node/register');require('${workerPath}')` : workerPath, {
|
56
|
+
const worker = new worker_threads.Worker(isTs ? TS_USE_ESM ? throwError("Native esm in `.ts` file is not supported yet, please use `.cjs` instead") : `require('ts-node/register');require('${workerPath}')` : workerPath, {
|
124
57
|
eval: isTs,
|
125
58
|
workerData: { workerPort },
|
126
59
|
transferList: [workerPort],
|
@@ -141,7 +74,7 @@ function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE,
|
|
141
74
|
id: id2,
|
142
75
|
result,
|
143
76
|
error
|
144
|
-
} =
|
77
|
+
} = worker_threads.receiveMessageOnPort(mainPort).message;
|
145
78
|
if (id !== id2) {
|
146
79
|
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
147
80
|
}
|
@@ -154,40 +87,26 @@ function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE,
|
|
154
87
|
return syncFn;
|
155
88
|
}
|
156
89
|
function runAsWorker(fn) {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
90
|
+
if (!worker_threads.workerData) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
const { workerPort } = worker_threads.workerData;
|
94
|
+
worker_threads.parentPort.on("message", ({ sharedBuffer, id, args }) => {
|
95
|
+
(() => __async(this, null, function* () {
|
96
|
+
const sharedBufferView = new Int32Array(sharedBuffer);
|
162
97
|
let msg;
|
163
98
|
try {
|
164
|
-
msg = { result: yield fn(...args) };
|
165
|
-
} catch (
|
99
|
+
msg = { id, result: yield fn(...args) };
|
100
|
+
} catch (error) {
|
166
101
|
msg = {
|
167
|
-
|
102
|
+
id,
|
103
|
+
error
|
168
104
|
};
|
169
105
|
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
workerThreads.parentPort.on("message", ({ sharedBuffer, id, args }) => {
|
175
|
-
(() => __async(this, null, function* () {
|
176
|
-
const sharedBufferView = new Int32Array(sharedBuffer);
|
177
|
-
let msg;
|
178
|
-
try {
|
179
|
-
msg = { id, result: yield fn(...args) };
|
180
|
-
} catch (error) {
|
181
|
-
msg = {
|
182
|
-
id,
|
183
|
-
error
|
184
|
-
};
|
185
|
-
}
|
186
|
-
workerPort.postMessage(msg);
|
187
|
-
Atomics.add(sharedBufferView, 0, 1);
|
188
|
-
Atomics.notify(sharedBufferView, 0);
|
189
|
-
}))();
|
190
|
-
});
|
106
|
+
workerPort.postMessage(msg);
|
107
|
+
Atomics.add(sharedBufferView, 0, 1);
|
108
|
+
Atomics.notify(sharedBufferView, 0);
|
109
|
+
}))();
|
191
110
|
});
|
192
111
|
}
|
193
112
|
|
@@ -196,5 +115,3 @@ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
|
196
115
|
exports.DEFAULT_WORKER_BUFFER_SIZE = DEFAULT_WORKER_BUFFER_SIZE;
|
197
116
|
exports.createSyncFn = createSyncFn;
|
198
117
|
exports.runAsWorker = runAsWorker;
|
199
|
-
exports.tmpdir = tmpdir;
|
200
|
-
exports.useWorkerThreads = useWorkerThreads;
|
package/lib/index.d.ts
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
import { AnyAsyncFn, Syncify } from './types.js';
|
2
2
|
export * from './types.js';
|
3
|
-
/**
|
4
|
-
* @link https://github.com/sindresorhus/temp-dir/blob/main/index.js#L9
|
5
|
-
*/
|
6
|
-
export declare const tmpdir: string;
|
7
|
-
export declare const useWorkerThreads: boolean;
|
8
3
|
export declare const DEFAULT_BUFFER_SIZE: number | undefined;
|
9
4
|
export declare const DEFAULT_TIMEOUT: number | undefined;
|
10
5
|
export declare const DEFAULT_WORKER_BUFFER_SIZE: number;
|
11
6
|
export declare function createSyncFn<T extends AnyAsyncFn>(workerPath: string, bufferSize?: number, timeout?: number): Syncify<T>;
|
12
|
-
export declare function runAsWorker<T extends AnyAsyncFn>(fn: T):
|
7
|
+
export declare function runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void;
|
package/lib/index.js
CHANGED
@@ -1,34 +1,8 @@
|
|
1
1
|
import { __awaiter } from "tslib";
|
2
|
-
import { execSync } from 'child_process';
|
3
|
-
import { tmpdir as _tmpdir } from 'os';
|
4
2
|
import path from 'path';
|
5
|
-
import
|
6
|
-
import { createRequire } from 'module';
|
7
|
-
import { v4 as uuid } from 'uuid';
|
3
|
+
import { MessageChannel, Worker, receiveMessageOnPort, workerData, parentPort, } from 'worker_threads';
|
8
4
|
export * from './types.js';
|
9
|
-
|
10
|
-
* @link https://github.com/sindresorhus/temp-dir/blob/main/index.js#L9
|
11
|
-
*/
|
12
|
-
export const tmpdir = fs.realpathSync(_tmpdir());
|
13
|
-
let workerThreads;
|
14
|
-
const cjsRequire =
|
15
|
-
/* istanbul ignore next */
|
16
|
-
typeof require === 'undefined' ? createRequire(import.meta.url) : require;
|
17
|
-
try {
|
18
|
-
workerThreads = cjsRequire('worker_threads');
|
19
|
-
/* istanbul ignore if */
|
20
|
-
if (typeof workerThreads.receiveMessageOnPort !== 'function') {
|
21
|
-
workerThreads = undefined;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
catch (_a) { }
|
25
|
-
/* istanbul ignore if */
|
26
|
-
if (!workerThreads) {
|
27
|
-
console.warn('[synckit]: `worker_threads` or `receiveMessageOnPort` is not available in current environment, `Node >= 12` is required');
|
28
|
-
}
|
29
|
-
const { SYNCKIT_WORKER_THREADS, SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT, SYNCKIT_TS_ESM, } = process.env;
|
30
|
-
export const useWorkerThreads = !!workerThreads &&
|
31
|
-
(!SYNCKIT_WORKER_THREADS || !['0', 'false'].includes(SYNCKIT_WORKER_THREADS));
|
5
|
+
const { SYNCKIT_BUFFER_SIZE, SYNCKIT_TIMEOUT, SYNCKIT_TS_ESM } = process.env;
|
32
6
|
const TS_USE_ESM = !!SYNCKIT_TS_ESM && ['1', 'true'].includes(SYNCKIT_TS_ESM);
|
33
7
|
export const DEFAULT_BUFFER_SIZE = SYNCKIT_BUFFER_SIZE
|
34
8
|
? +SYNCKIT_BUFFER_SIZE
|
@@ -44,45 +18,14 @@ export function createSyncFn(workerPath, bufferSize, timeout = DEFAULT_TIMEOUT)
|
|
44
18
|
if (cachedSyncFn) {
|
45
19
|
return cachedSyncFn;
|
46
20
|
}
|
47
|
-
const syncFn =
|
21
|
+
const syncFn = startWorkerThread(workerPath, bufferSize, timeout);
|
48
22
|
syncFnCache.set(workerPath, syncFn);
|
49
23
|
return syncFn;
|
50
24
|
}
|
51
|
-
function startChildProcess(workerPath, bufferSize = DEFAULT_BUFFER_SIZE, timeout) {
|
52
|
-
const executor = workerPath.endsWith('.ts')
|
53
|
-
? TS_USE_ESM
|
54
|
-
? 'node --loader ts-node/esm'
|
55
|
-
: 'ts-node'
|
56
|
-
: 'node';
|
57
|
-
return (...args) => {
|
58
|
-
const filename = path.resolve(tmpdir, `synckit-${uuid()}.json`);
|
59
|
-
fs.writeFileSync(filename, JSON.stringify(args));
|
60
|
-
const command = `${executor} ${workerPath} ${filename}`;
|
61
|
-
try {
|
62
|
-
execSync(command, {
|
63
|
-
stdio: 'inherit',
|
64
|
-
maxBuffer: bufferSize,
|
65
|
-
timeout,
|
66
|
-
});
|
67
|
-
const { result, error } = JSON.parse(fs.readFileSync(filename, 'utf8'));
|
68
|
-
if (error) {
|
69
|
-
throw typeof error === 'object' && 'message' in error
|
70
|
-
? // eslint-disable-next-line unicorn/error-message
|
71
|
-
Object.assign(new Error(), error)
|
72
|
-
: error;
|
73
|
-
}
|
74
|
-
return result;
|
75
|
-
}
|
76
|
-
finally {
|
77
|
-
fs.unlinkSync(filename);
|
78
|
-
}
|
79
|
-
};
|
80
|
-
}
|
81
25
|
const throwError = (msg) => {
|
82
26
|
throw new Error(msg);
|
83
27
|
};
|
84
28
|
function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE, timeout) {
|
85
|
-
const { MessageChannel, Worker } = workerThreads;
|
86
29
|
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
87
30
|
const isTs = workerPath.endsWith('.ts');
|
88
31
|
const worker = new Worker(isTs
|
@@ -107,8 +50,7 @@ function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE,
|
|
107
50
|
if (!['ok', 'not-equal'].includes(status)) {
|
108
51
|
throw new Error('Internal error: Atomics.wait() failed: ' + status);
|
109
52
|
}
|
110
|
-
const { id: id2, result, error, } =
|
111
|
-
.message;
|
53
|
+
const { id: id2, result, error, } = receiveMessageOnPort(mainPort).message;
|
112
54
|
/* istanbul ignore if */
|
113
55
|
if (id !== id2) {
|
114
56
|
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
@@ -121,48 +63,31 @@ function startWorkerThread(workerPath, bufferSize = DEFAULT_WORKER_BUFFER_SIZE,
|
|
121
63
|
worker.unref();
|
122
64
|
return syncFn;
|
123
65
|
}
|
66
|
+
/* istanbul ignore next */
|
124
67
|
export function runAsWorker(fn) {
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
68
|
+
if (!workerData) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
const { workerPort } = workerData;
|
72
|
+
parentPort.on('message', ({ sharedBuffer, id, args }) => {
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
74
|
+
;
|
75
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
76
|
+
const sharedBufferView = new Int32Array(sharedBuffer);
|
130
77
|
let msg;
|
131
78
|
try {
|
132
|
-
msg = { result: yield fn(...args) };
|
79
|
+
msg = { id, result: yield fn(...args) };
|
133
80
|
}
|
134
|
-
catch (
|
81
|
+
catch (error) {
|
135
82
|
msg = {
|
136
|
-
|
137
|
-
|
83
|
+
id,
|
84
|
+
error,
|
138
85
|
};
|
139
86
|
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
const { workerPort } = workerThreads.workerData;
|
145
|
-
/* istanbul ignore next */
|
146
|
-
workerThreads.parentPort.on('message', ({ sharedBuffer, id, args }) => {
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
148
|
-
;
|
149
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
150
|
-
const sharedBufferView = new Int32Array(sharedBuffer);
|
151
|
-
let msg;
|
152
|
-
try {
|
153
|
-
msg = { id, result: yield fn(...args) };
|
154
|
-
}
|
155
|
-
catch (error) {
|
156
|
-
msg = {
|
157
|
-
id,
|
158
|
-
error,
|
159
|
-
};
|
160
|
-
}
|
161
|
-
workerPort.postMessage(msg);
|
162
|
-
Atomics.add(sharedBufferView, 0, 1);
|
163
|
-
Atomics.notify(sharedBufferView, 0);
|
164
|
-
}))();
|
165
|
-
});
|
87
|
+
workerPort.postMessage(msg);
|
88
|
+
Atomics.add(sharedBufferView, 0, 1);
|
89
|
+
Atomics.notify(sharedBufferView, 0);
|
90
|
+
}))();
|
166
91
|
});
|
167
92
|
}
|
168
93
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,cAAc,EACd,MAAM,EACN,oBAAoB,EACpB,UAAU,EACV,UAAU,GACX,MAAM,gBAAgB,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"name": "synckit",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.0",
|
4
4
|
"type": "module",
|
5
5
|
"description": "Perform async work synchronously in Node.js using `worker_threads`, or `child_process` as fallback, with first-class TypeScript support.",
|
6
6
|
"repository": "git+https://github.com/rx-ts/synckit.git",
|
7
7
|
"author": "JounQin <admin@1stg.me>",
|
8
8
|
"license": "MIT",
|
9
9
|
"engines": {
|
10
|
-
"node": ">=12"
|
10
|
+
"node": ">=12.3"
|
11
11
|
},
|
12
|
-
"main": "./lib/index.cjs",
|
13
|
-
"module": "./lib/index.js",
|
14
12
|
"exports": {
|
15
13
|
"import": "./lib/index.js",
|
16
14
|
"require": "./lib/index.cjs"
|
@@ -51,8 +49,7 @@
|
|
51
49
|
"typecov": "type-coverage"
|
52
50
|
},
|
53
51
|
"dependencies": {
|
54
|
-
"tslib": "^2.3.1"
|
55
|
-
"uuid": "^8.3.2"
|
52
|
+
"tslib": "^2.3.1"
|
56
53
|
},
|
57
54
|
"devDependencies": {
|
58
55
|
"@1stg/lib-config": "^4.0.0",
|