Thread Func
Description
This is a TypeScript library that provides a simple way to run functions in separate threads.
Installation
You can install this library using npm:
npm install thread-func
Usage
import { threadFunc } from 'thread-func';
export const method = threadFunc(async (input: number) => {
return input * 42;
});
Signature
threadFunc<T, R>(func: (input: T) => Promise<R>, options): (input: T) => Promise<R>;
Options
{
maxThreads: number = Infinity;
variant: 'child_process' | 'worker_threads' = 'worker_threads';
}
License
This library is licensed under the MIT license.