defuss-multicore 0.0.1
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/README.md +314 -0
- package/dist/index.cjs +601 -0
- package/dist/index.d.cts +162 -0
- package/dist/index.d.mts +162 -0
- package/dist/index.mjs +590 -0
- package/dist/pool-DhG3ybwo.mjs +151 -0
- package/dist/pool-DqNSYahJ.cjs +153 -0
- package/dist/pool-browser-BsBdOUwc.cjs +43 -0
- package/dist/pool-browser-IHMOtzRq.mjs +41 -0
- package/dist/pool-node-Chmgg6NZ.mjs +35 -0
- package/dist/pool-node-DKGzL78_.cjs +38 -0
- package/package.json +73 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { getPoolSize as getCoreCount } from './index.mjs';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 3e4;
|
|
4
|
+
const createPool = (script, config, hooks) => {
|
|
5
|
+
const maxWorkers = config.maxWorkers ?? getCoreCount();
|
|
6
|
+
const idleTimeoutMs = config.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
|
|
7
|
+
const workers = [];
|
|
8
|
+
const queue = [];
|
|
9
|
+
let nextId = 0;
|
|
10
|
+
let taskCounter = 0;
|
|
11
|
+
const pending = /* @__PURE__ */ new Map();
|
|
12
|
+
const onMessage = (handle, data) => {
|
|
13
|
+
const p = pending.get(data.id);
|
|
14
|
+
if (!p) return;
|
|
15
|
+
pending.delete(data.id);
|
|
16
|
+
handle.busy = false;
|
|
17
|
+
resetIdleTimer(handle);
|
|
18
|
+
drainQueue();
|
|
19
|
+
if (data.type === "result") {
|
|
20
|
+
p.resolve(data.value);
|
|
21
|
+
} else {
|
|
22
|
+
const err = new Error(data.error);
|
|
23
|
+
if (data.stack) err.stack = data.stack;
|
|
24
|
+
p.reject(err);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const onError = (handle, error) => {
|
|
28
|
+
for (const [id, p] of pending) {
|
|
29
|
+
p.reject(error instanceof Error ? error : new Error(String(error)));
|
|
30
|
+
pending.delete(id);
|
|
31
|
+
}
|
|
32
|
+
handle.busy = false;
|
|
33
|
+
handle.terminated = true;
|
|
34
|
+
};
|
|
35
|
+
const spawnWorker = () => {
|
|
36
|
+
const id = nextId++;
|
|
37
|
+
const raw = hooks.createWorker(script, id);
|
|
38
|
+
const handle = { id, busy: false, terminated: false, raw };
|
|
39
|
+
hooks.onMessage(raw, (data) => onMessage(handle, data));
|
|
40
|
+
hooks.onError(raw, (err) => onError(handle, err));
|
|
41
|
+
workers.push(handle);
|
|
42
|
+
resetIdleTimer(handle);
|
|
43
|
+
return handle;
|
|
44
|
+
};
|
|
45
|
+
const resetIdleTimer = (handle) => {
|
|
46
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
47
|
+
handle.idleTimer = setTimeout(() => {
|
|
48
|
+
if (!handle.busy && !handle.terminated) {
|
|
49
|
+
handle.terminated = true;
|
|
50
|
+
hooks.terminateWorker(handle.raw);
|
|
51
|
+
const idx = workers.indexOf(handle);
|
|
52
|
+
if (idx !== -1) workers.splice(idx, 1);
|
|
53
|
+
}
|
|
54
|
+
}, idleTimeoutMs);
|
|
55
|
+
};
|
|
56
|
+
const getIdleWorker = () => workers.find((w) => !w.busy && !w.terminated);
|
|
57
|
+
const drainQueue = () => {
|
|
58
|
+
while (queue.length > 0) {
|
|
59
|
+
const idle = getIdleWorker();
|
|
60
|
+
if (!idle) {
|
|
61
|
+
if (workers.length < maxWorkers) {
|
|
62
|
+
const fresh = spawnWorker();
|
|
63
|
+
const task2 = queue.shift();
|
|
64
|
+
dispatch(fresh, task2);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const task = queue.shift();
|
|
69
|
+
dispatch(idle, task);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const dispatch = (handle, task) => {
|
|
73
|
+
const id = `t${taskCounter++}`;
|
|
74
|
+
handle.busy = true;
|
|
75
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
76
|
+
pending.set(id, { resolve: task.resolve, reject: task.reject });
|
|
77
|
+
if (task.signal?.aborted) {
|
|
78
|
+
pending.delete(id);
|
|
79
|
+
handle.busy = false;
|
|
80
|
+
resetIdleTimer(handle);
|
|
81
|
+
task.reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (task.signal) {
|
|
85
|
+
const onAbort = () => {
|
|
86
|
+
const p = pending.get(id);
|
|
87
|
+
if (p) {
|
|
88
|
+
pending.delete(id);
|
|
89
|
+
handle.terminated = true;
|
|
90
|
+
hooks.terminateWorker(handle.raw);
|
|
91
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
92
|
+
const idx = workers.indexOf(handle);
|
|
93
|
+
if (idx !== -1) workers.splice(idx, 1);
|
|
94
|
+
p.reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
task.signal.addEventListener("abort", onAbort, { once: true });
|
|
98
|
+
}
|
|
99
|
+
hooks.postMessage(
|
|
100
|
+
handle.raw,
|
|
101
|
+
{ type: "execute", id, args: task.args },
|
|
102
|
+
task.transfer ?? []
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
const pool = {
|
|
106
|
+
get size() {
|
|
107
|
+
return maxWorkers;
|
|
108
|
+
},
|
|
109
|
+
execute(args, transfer, signal) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
const task = { args, transfer, signal, resolve, reject };
|
|
112
|
+
const idle = getIdleWorker();
|
|
113
|
+
if (idle) {
|
|
114
|
+
dispatch(idle, task);
|
|
115
|
+
} else if (workers.length < maxWorkers) {
|
|
116
|
+
const fresh = spawnWorker();
|
|
117
|
+
dispatch(fresh, task);
|
|
118
|
+
} else {
|
|
119
|
+
queue.push(task);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
warmup(count) {
|
|
124
|
+
const target = Math.min(count ?? maxWorkers, maxWorkers);
|
|
125
|
+
while (workers.length < target) {
|
|
126
|
+
spawnWorker();
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
async terminate() {
|
|
130
|
+
for (const w of workers) {
|
|
131
|
+
if (!w.terminated) {
|
|
132
|
+
w.terminated = true;
|
|
133
|
+
if (w.idleTimer) clearTimeout(w.idleTimer);
|
|
134
|
+
hooks.terminateWorker(w.raw);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
workers.length = 0;
|
|
138
|
+
for (const task of queue) {
|
|
139
|
+
task.reject(new Error("Pool terminated"));
|
|
140
|
+
}
|
|
141
|
+
queue.length = 0;
|
|
142
|
+
for (const [, p] of pending) {
|
|
143
|
+
p.reject(new Error("Pool terminated"));
|
|
144
|
+
}
|
|
145
|
+
pending.clear();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return pool;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export { createPool as c };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index.cjs');
|
|
4
|
+
|
|
5
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 3e4;
|
|
6
|
+
const createPool = (script, config, hooks) => {
|
|
7
|
+
const maxWorkers = config.maxWorkers ?? index.getPoolSize();
|
|
8
|
+
const idleTimeoutMs = config.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
|
|
9
|
+
const workers = [];
|
|
10
|
+
const queue = [];
|
|
11
|
+
let nextId = 0;
|
|
12
|
+
let taskCounter = 0;
|
|
13
|
+
const pending = /* @__PURE__ */ new Map();
|
|
14
|
+
const onMessage = (handle, data) => {
|
|
15
|
+
const p = pending.get(data.id);
|
|
16
|
+
if (!p) return;
|
|
17
|
+
pending.delete(data.id);
|
|
18
|
+
handle.busy = false;
|
|
19
|
+
resetIdleTimer(handle);
|
|
20
|
+
drainQueue();
|
|
21
|
+
if (data.type === "result") {
|
|
22
|
+
p.resolve(data.value);
|
|
23
|
+
} else {
|
|
24
|
+
const err = new Error(data.error);
|
|
25
|
+
if (data.stack) err.stack = data.stack;
|
|
26
|
+
p.reject(err);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const onError = (handle, error) => {
|
|
30
|
+
for (const [id, p] of pending) {
|
|
31
|
+
p.reject(error instanceof Error ? error : new Error(String(error)));
|
|
32
|
+
pending.delete(id);
|
|
33
|
+
}
|
|
34
|
+
handle.busy = false;
|
|
35
|
+
handle.terminated = true;
|
|
36
|
+
};
|
|
37
|
+
const spawnWorker = () => {
|
|
38
|
+
const id = nextId++;
|
|
39
|
+
const raw = hooks.createWorker(script, id);
|
|
40
|
+
const handle = { id, busy: false, terminated: false, raw };
|
|
41
|
+
hooks.onMessage(raw, (data) => onMessage(handle, data));
|
|
42
|
+
hooks.onError(raw, (err) => onError(handle, err));
|
|
43
|
+
workers.push(handle);
|
|
44
|
+
resetIdleTimer(handle);
|
|
45
|
+
return handle;
|
|
46
|
+
};
|
|
47
|
+
const resetIdleTimer = (handle) => {
|
|
48
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
49
|
+
handle.idleTimer = setTimeout(() => {
|
|
50
|
+
if (!handle.busy && !handle.terminated) {
|
|
51
|
+
handle.terminated = true;
|
|
52
|
+
hooks.terminateWorker(handle.raw);
|
|
53
|
+
const idx = workers.indexOf(handle);
|
|
54
|
+
if (idx !== -1) workers.splice(idx, 1);
|
|
55
|
+
}
|
|
56
|
+
}, idleTimeoutMs);
|
|
57
|
+
};
|
|
58
|
+
const getIdleWorker = () => workers.find((w) => !w.busy && !w.terminated);
|
|
59
|
+
const drainQueue = () => {
|
|
60
|
+
while (queue.length > 0) {
|
|
61
|
+
const idle = getIdleWorker();
|
|
62
|
+
if (!idle) {
|
|
63
|
+
if (workers.length < maxWorkers) {
|
|
64
|
+
const fresh = spawnWorker();
|
|
65
|
+
const task2 = queue.shift();
|
|
66
|
+
dispatch(fresh, task2);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
const task = queue.shift();
|
|
71
|
+
dispatch(idle, task);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const dispatch = (handle, task) => {
|
|
75
|
+
const id = `t${taskCounter++}`;
|
|
76
|
+
handle.busy = true;
|
|
77
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
78
|
+
pending.set(id, { resolve: task.resolve, reject: task.reject });
|
|
79
|
+
if (task.signal?.aborted) {
|
|
80
|
+
pending.delete(id);
|
|
81
|
+
handle.busy = false;
|
|
82
|
+
resetIdleTimer(handle);
|
|
83
|
+
task.reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (task.signal) {
|
|
87
|
+
const onAbort = () => {
|
|
88
|
+
const p = pending.get(id);
|
|
89
|
+
if (p) {
|
|
90
|
+
pending.delete(id);
|
|
91
|
+
handle.terminated = true;
|
|
92
|
+
hooks.terminateWorker(handle.raw);
|
|
93
|
+
if (handle.idleTimer) clearTimeout(handle.idleTimer);
|
|
94
|
+
const idx = workers.indexOf(handle);
|
|
95
|
+
if (idx !== -1) workers.splice(idx, 1);
|
|
96
|
+
p.reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
task.signal.addEventListener("abort", onAbort, { once: true });
|
|
100
|
+
}
|
|
101
|
+
hooks.postMessage(
|
|
102
|
+
handle.raw,
|
|
103
|
+
{ type: "execute", id, args: task.args },
|
|
104
|
+
task.transfer ?? []
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
const pool = {
|
|
108
|
+
get size() {
|
|
109
|
+
return maxWorkers;
|
|
110
|
+
},
|
|
111
|
+
execute(args, transfer, signal) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
const task = { args, transfer, signal, resolve, reject };
|
|
114
|
+
const idle = getIdleWorker();
|
|
115
|
+
if (idle) {
|
|
116
|
+
dispatch(idle, task);
|
|
117
|
+
} else if (workers.length < maxWorkers) {
|
|
118
|
+
const fresh = spawnWorker();
|
|
119
|
+
dispatch(fresh, task);
|
|
120
|
+
} else {
|
|
121
|
+
queue.push(task);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
warmup(count) {
|
|
126
|
+
const target = Math.min(count ?? maxWorkers, maxWorkers);
|
|
127
|
+
while (workers.length < target) {
|
|
128
|
+
spawnWorker();
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
async terminate() {
|
|
132
|
+
for (const w of workers) {
|
|
133
|
+
if (!w.terminated) {
|
|
134
|
+
w.terminated = true;
|
|
135
|
+
if (w.idleTimer) clearTimeout(w.idleTimer);
|
|
136
|
+
hooks.terminateWorker(w.raw);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
workers.length = 0;
|
|
140
|
+
for (const task of queue) {
|
|
141
|
+
task.reject(new Error("Pool terminated"));
|
|
142
|
+
}
|
|
143
|
+
queue.length = 0;
|
|
144
|
+
for (const [, p] of pending) {
|
|
145
|
+
p.reject(new Error("Pool terminated"));
|
|
146
|
+
}
|
|
147
|
+
pending.clear();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
return pool;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
exports.createPool = createPool;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pool = require('./pool-DqNSYahJ.cjs');
|
|
4
|
+
require('./index.cjs');
|
|
5
|
+
|
|
6
|
+
const createBrowserPool = (script, config) => {
|
|
7
|
+
const blobUrls = /* @__PURE__ */ new Set();
|
|
8
|
+
const hooks = {
|
|
9
|
+
createWorker(script2) {
|
|
10
|
+
const blob = new Blob([script2], { type: "text/javascript" });
|
|
11
|
+
const url = URL.createObjectURL(blob);
|
|
12
|
+
blobUrls.add(url);
|
|
13
|
+
return new Worker(url);
|
|
14
|
+
},
|
|
15
|
+
postMessage(worker, data, transfer) {
|
|
16
|
+
worker.postMessage(data, transfer);
|
|
17
|
+
},
|
|
18
|
+
terminateWorker(worker) {
|
|
19
|
+
worker.terminate();
|
|
20
|
+
},
|
|
21
|
+
onMessage(worker, handler) {
|
|
22
|
+
worker.onmessage = (e) => handler(e.data);
|
|
23
|
+
},
|
|
24
|
+
onError(worker, handler) {
|
|
25
|
+
worker.onerror = (e) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
handler(new Error(e.message));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const pool$1 = pool.createPool(script, config ?? {}, hooks);
|
|
32
|
+
const originalTerminate = pool$1.terminate.bind(pool$1);
|
|
33
|
+
pool$1.terminate = async () => {
|
|
34
|
+
await originalTerminate();
|
|
35
|
+
for (const url of blobUrls) {
|
|
36
|
+
URL.revokeObjectURL(url);
|
|
37
|
+
}
|
|
38
|
+
blobUrls.clear();
|
|
39
|
+
};
|
|
40
|
+
return pool$1;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.createBrowserPool = createBrowserPool;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { c as createPool } from './pool-DhG3ybwo.mjs';
|
|
2
|
+
import './index.mjs';
|
|
3
|
+
|
|
4
|
+
const createBrowserPool = (script, config) => {
|
|
5
|
+
const blobUrls = /* @__PURE__ */ new Set();
|
|
6
|
+
const hooks = {
|
|
7
|
+
createWorker(script2) {
|
|
8
|
+
const blob = new Blob([script2], { type: "text/javascript" });
|
|
9
|
+
const url = URL.createObjectURL(blob);
|
|
10
|
+
blobUrls.add(url);
|
|
11
|
+
return new Worker(url);
|
|
12
|
+
},
|
|
13
|
+
postMessage(worker, data, transfer) {
|
|
14
|
+
worker.postMessage(data, transfer);
|
|
15
|
+
},
|
|
16
|
+
terminateWorker(worker) {
|
|
17
|
+
worker.terminate();
|
|
18
|
+
},
|
|
19
|
+
onMessage(worker, handler) {
|
|
20
|
+
worker.onmessage = (e) => handler(e.data);
|
|
21
|
+
},
|
|
22
|
+
onError(worker, handler) {
|
|
23
|
+
worker.onerror = (e) => {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
handler(new Error(e.message));
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const pool = createPool(script, config ?? {}, hooks);
|
|
30
|
+
const originalTerminate = pool.terminate.bind(pool);
|
|
31
|
+
pool.terminate = async () => {
|
|
32
|
+
await originalTerminate();
|
|
33
|
+
for (const url of blobUrls) {
|
|
34
|
+
URL.revokeObjectURL(url);
|
|
35
|
+
}
|
|
36
|
+
blobUrls.clear();
|
|
37
|
+
};
|
|
38
|
+
return pool;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { createBrowserPool };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { c as createPool } from './pool-DhG3ybwo.mjs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import './index.mjs';
|
|
4
|
+
|
|
5
|
+
const createNodePool = (script, config) => {
|
|
6
|
+
let WorkerClass;
|
|
7
|
+
try {
|
|
8
|
+
const _require = createRequire(import.meta.url);
|
|
9
|
+
WorkerClass = _require("node:worker_threads").Worker;
|
|
10
|
+
} catch {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"[defuss-multicore] node:worker_threads not available. Are you running in Node.js?"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
const hooks = {
|
|
16
|
+
createWorker(script2) {
|
|
17
|
+
return new WorkerClass(script2, { eval: true });
|
|
18
|
+
},
|
|
19
|
+
postMessage(worker, data, transfer) {
|
|
20
|
+
worker.postMessage(data, transfer);
|
|
21
|
+
},
|
|
22
|
+
terminateWorker(worker) {
|
|
23
|
+
worker.terminate();
|
|
24
|
+
},
|
|
25
|
+
onMessage(worker, handler) {
|
|
26
|
+
worker.on("message", handler);
|
|
27
|
+
},
|
|
28
|
+
onError(worker, handler) {
|
|
29
|
+
worker.on("error", handler);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return createPool(script, config ?? {}, hooks);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { createNodePool };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pool = require('./pool-DqNSYahJ.cjs');
|
|
4
|
+
var node_module = require('node:module');
|
|
5
|
+
require('./index.cjs');
|
|
6
|
+
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
|
+
const createNodePool = (script, config) => {
|
|
9
|
+
let WorkerClass;
|
|
10
|
+
try {
|
|
11
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('pool-node-DKGzL78_.cjs', document.baseURI).href)));
|
|
12
|
+
WorkerClass = _require("node:worker_threads").Worker;
|
|
13
|
+
} catch {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"[defuss-multicore] node:worker_threads not available. Are you running in Node.js?"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
const hooks = {
|
|
19
|
+
createWorker(script2) {
|
|
20
|
+
return new WorkerClass(script2, { eval: true });
|
|
21
|
+
},
|
|
22
|
+
postMessage(worker, data, transfer) {
|
|
23
|
+
worker.postMessage(data, transfer);
|
|
24
|
+
},
|
|
25
|
+
terminateWorker(worker) {
|
|
26
|
+
worker.terminate();
|
|
27
|
+
},
|
|
28
|
+
onMessage(worker, handler) {
|
|
29
|
+
worker.on("message", handler);
|
|
30
|
+
},
|
|
31
|
+
onError(worker, handler) {
|
|
32
|
+
worker.on("error", handler);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return pool.createPool(script, config ?? {}, hooks);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.createNodePool = createNodePool;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "defuss-multicore",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"description": "Isomorphic multicore execution + linear algebra. Web Workers (browser) + worker_threads (Node.js). Auto-split, loop-unrolled vector/matrix ops, parallel map/filter/reduce.",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"multicore",
|
|
12
|
+
"parallel",
|
|
13
|
+
"worker",
|
|
14
|
+
"web-worker",
|
|
15
|
+
"worker-threads",
|
|
16
|
+
"isomorphic",
|
|
17
|
+
"matrix",
|
|
18
|
+
"vector",
|
|
19
|
+
"dotproduct",
|
|
20
|
+
"matmul",
|
|
21
|
+
"loop-unrolling",
|
|
22
|
+
"simd",
|
|
23
|
+
"typed-array"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"url": "git+https://github.com/kyr0/defuss.git",
|
|
27
|
+
"type": "git"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"clean": "rm -rf ./dist && rm -rf ./node_modules/.bun",
|
|
31
|
+
"pretest": "bun run build",
|
|
32
|
+
"prebuild": "bun run clean",
|
|
33
|
+
"build": "pkgroll",
|
|
34
|
+
"test": "vitest --run --coverage",
|
|
35
|
+
"test:browser": "vitest --run --config vitest.browser.config.ts",
|
|
36
|
+
"bench": "node --import tsx/esm src/bench.ts",
|
|
37
|
+
"bench:browser": "vitest --run --config vitest.browser.config.ts --testNamePattern=benchmark",
|
|
38
|
+
"prepublishOnly": "bun run build"
|
|
39
|
+
},
|
|
40
|
+
"author": "Aron Homberg <info@aron-homberg.de>",
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/index.d.cts",
|
|
46
|
+
"default": "./dist/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./dist/index.d.mts",
|
|
50
|
+
"default": "./dist/index.mjs"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"main": "./dist/index.cjs",
|
|
55
|
+
"module": "./dist/index.mjs",
|
|
56
|
+
"types": "./dist/index.d.cts",
|
|
57
|
+
"files": [
|
|
58
|
+
"dist"
|
|
59
|
+
],
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@vitest/browser": "^4.1.2",
|
|
65
|
+
"@vitest/browser-playwright": "^4.1.2",
|
|
66
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
67
|
+
"pkgroll": "^2.21.5",
|
|
68
|
+
"playwright": "^1.58.2",
|
|
69
|
+
"tsx": "^4.21.0",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"vitest": "^4.1.2"
|
|
72
|
+
}
|
|
73
|
+
}
|