1.1.0 • Published 5 months ago

thread-func v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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.

1.0.2

5 months ago

1.1.0

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago