- binary-search-closest.git
- src
- util.worker.js
This file ( 601B ) exceeds the allowed full mode (48 kb) size.
The editor full hight is disabled, only scrolling is allowed..
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height
mode, although some users like it.
const worker = async (options) => {
const { Worker } = require('worker_threads');
const workerResult = await new Promise((resolve, reject) => {
const worker = new Worker(`${__dirname}/worker.js`, {
workerData: options
});
worker.on('message', resolve);
worker.on('error', reject);
worker.on('exit', (code) => {
if (code !== 0) {
reject(new Error(`Worker stopped with exit code ${code}`));
}
worker.terminate()
});
});
return workerResult
};
module.exports.worker = worker