Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: add type checking setup and gitignore

Add typescript and @types/node as devDependencies, fix tsconfig for
node types and Symbol.dispose, clean up worker-pool.ts type issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+66 -15
+3
.gitignore
··· 1 + node_modules 2 + .claude 3 + docs
+4
package.json
··· 6 6 "packageManager": "pnpm@10.33.0", 7 7 "scripts": { 8 8 "test": "node --experimental-strip-types --test --test-force-exit test/**/*.test.ts" 9 + }, 10 + "devDependencies": { 11 + "@types/node": "^25.5.2", 12 + "typescript": "^6.0.2" 9 13 } 10 14 }
+39
pnpm-lock.yaml
··· 1 + lockfileVersion: '9.0' 2 + 3 + settings: 4 + autoInstallPeers: true 5 + excludeLinksFromLockfile: false 6 + 7 + importers: 8 + 9 + .: 10 + devDependencies: 11 + '@types/node': 12 + specifier: ^25.5.2 13 + version: 25.5.2 14 + typescript: 15 + specifier: ^6.0.2 16 + version: 6.0.2 17 + 18 + packages: 19 + 20 + '@types/node@25.5.2': 21 + resolution: {integrity: sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==} 22 + 23 + typescript@6.0.2: 24 + resolution: {integrity: sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==} 25 + engines: {node: '>=14.17'} 26 + hasBin: true 27 + 28 + undici-types@7.18.2: 29 + resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==} 30 + 31 + snapshots: 32 + 33 + '@types/node@25.5.2': 34 + dependencies: 35 + undici-types: 7.18.2 36 + 37 + typescript@6.0.2: {} 38 + 39 + undici-types@7.18.2: {}
+18 -15
src/worker-pool.ts
··· 17 17 let next = 0; 18 18 let disposed = false; 19 19 20 - const run = <T>(task: Task<T>): Promise<T> => { 21 - if (disposed) return Promise.reject(new Error('Worker pool is disposed')); 22 - const worker = workers[next % workers.length]; 23 - next++; 24 - return execute<T>(worker, task.id, task.args); 25 - }; 20 + const run: Runner = Object.assign( 21 + <T>(task: Task<T>): Promise<T> => { 22 + if (disposed) return Promise.reject(new Error('Worker pool is disposed')); 23 + const worker = workers[next % workers.length]; 24 + next++; 25 + return execute<T>(worker, task.id, task.args); 26 + }, 27 + { 28 + [Symbol.dispose]() { 29 + disposed = true; 30 + for (const worker of workers) { 31 + worker.terminate(); 32 + } 33 + workers.length = 0; 34 + }, 35 + }, 36 + ); 26 37 27 - run[Symbol.dispose] = () => { 28 - disposed = true; 29 - for (const worker of workers) { 30 - worker.terminate(); 31 - } 32 - workers.length = 0; 33 - }; 34 - 35 - return run as Runner; 38 + return run; 36 39 }
+2
tsconfig.json
··· 1 1 { 2 2 "compilerOptions": { 3 3 "target": "es2022", 4 + "lib": ["es2022", "esnext.disposable"], 5 + "types": ["node"], 4 6 "module": "nodenext", 5 7 "moduleResolution": "nodenext", 6 8 "strict": true,