nanolith
Version:
Multi-threading in no time with seamless TypeScript support.
23 lines (22 loc) • 1.01 kB
TypeScript
import type { DefineOptions, TaskDefinitions } from '../types/definitions.js';
import type { Nanolith } from '../types/nanolith.js';
/**
* It all starts here 😎
*
* @param definitions A set of named function definitions. The functions you provide can be either synchronous or asynchronous.
* @param options An optional set of {@link DefineOptions}. The `file` can be specified (if necessary),
* as well as a unique `identifier` for the set of definitions.
*
* @example
* import { define } from 'nanolith';
*
* export const math = await define({
* add: (x: number, y: number) => x + y,
* subtract: (x: number, y: number) => x - y,
* waitThenAdd: async (x: number, y: number) => {
* await new Promise((resolve) => setTimeout(resolve, 5000));
* return x + y;
* },
* });
*/
export declare function define<Definitions extends TaskDefinitions>(definitions: Definitions, { identifier, file: fileFromOptions, safeMode, }?: DefineOptions): Promise<Nanolith<Definitions>>;