@e-mc/task
TypeScript icon, indicating that this package has built-in type declarations

0.10.2 • Public • Published

@e-mc/task

  • NodeJS 16
  • ES2020

General Usage

Interface

import type { IFileManager, IHost, ModuleConstructor } from "./index";
import type { ExternalAsset, IFileThread } from "./asset";
import type { IClient } from "./core";
import type { TaskModule } from "./settings";
import type { Command, SpawnResult } from "./task";

interface ITask extends IClient<IHost, TaskModule> {
    using?(data: IFileThread): Promise<unknown>;
    collect?(items: unknown[], preceding?: boolean): Promise<SpawnResult>[];
    map?(tasks: Command[]): Promise<SpawnResult | void>[];
    series?(tasks: Command[]): Promise<unknown>;
    parallel?(tasks: Command[]): Promise<unknown>;
    spawn?(task: Record<string | number | symbol, unknown>, callback: (result?: SpawnResult) => void): void;
    execute?(manager: IFileManager, task: Record<string | number | symbol, unknown>, callback: (value?: unknown) => void): void;
}

interface TaskConstructor extends ModuleConstructor {
    finalize(this: IHost, instance: ITask, assets: ExternalAsset[]): Promise<void>;
    readonly prototype: ITask;
    new(module?: TaskModule, ...args: unknown[]): ITask;
}

Settings

import type { PermittedDirectories } from "./core";

interface TaskModule {
    // handler: "@pi-r/gulp";
    settings?: {
        broadcast_id?: string | string[];
        users?: Record<string, Record<string, unknown>>;
        exec?: {
            uid?: number;
            gid?: number;
        };
    };
    permission?: PermittedDirectories;
}

Example usage

NOTE: Usage without a Host is conducted through static methods. The using class method is called by the Host to perform the transformation.

References

LICENSE

BSD 3-Clause

Package Sidebar

Install

npm i @e-mc/task

Weekly Downloads

535

Version

0.10.2

License

BSD 3-Clause

Unpacked Size

4.46 kB

Total Files

5

Last publish

Collaborators

  • anpham6