UNPKG

funthreads

Version:

A lightweight tool built on top of Node.js worker_threads, enabling multithreading.

15 lines (11 loc) 288 B
const { executeInThread } = require('funthreads'); // this will be executed in a dedicated thread const task = () => Promise.reject(new Error('Something wrong!')); async function start() { try { await executeInThread(task); } catch (err) { console.log(err); } } start();