Skip to content

DominicVonk/thread-func

Repository files navigation

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) => {
    // Some code
    return input * 42;
});

Signature

threadFunc<T, R>(func: (input: T) => Promise<R>, options): (input: T) => Promise<R>;

Options

{
    maxThreads: number = Infinity; // Maximum number of threads to run in parallel.
    variant: 'child_process' | 'worker_threads' = 'worker_threads'; // The type of thread to use.
}

License

This library is licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published