| 1 | const { parentPort } = require('node:worker_threads') |
| 2 | const { statSync } = require('node:fs') |
| 3 | |
| 4 | parentPort.on('message', async path => { |
| 5 | try { // we use statSync to not use (and not risk to saturate) libuv's thread pool |
| 6 | parentPort.postMessage({ path, result: { ...statSync(path) } }) |
| 7 | } catch (err) { |
| 8 | parentPort.postMessage({ path, error: err?.message || String(err) }) |
| 9 | } |
| 10 | }) |