Skip to main content
Home

@rt/task@0.0.0
Built and signed on GitHub Actions

The core tasks primitives for rt that enables creating custom tasks.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.0.0)

@rt/task

logo Work less. Do more.

Overview

The core tasks primitives for rt that enables creating custom tasks.

Basic Usage

import { 
    TaskBase, 
    TaskResult,
    registerTask, 
    type Task, 
    type TaskExecutionContext
} from str from '@rt/task'

export class SimpleTask extends TaskBase {
    run: (ctx: TaskExecutionContext) => Promise<void>
}

registerTask({
    id: "simple-task",
    match: function(task: Task) {
        return task instanceof SimpleTask
    },
    handler: async (ctx) => {
        const task = ctx.task as SimpleTask
        const result = new TaskResult(task);
        result.start();
        try {
            await task.run(ctx);
            return result.end();
        } catch(e) {
            return result.end('error', {}, e);
        }
    }
});

MIT License

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@rt/task

Import symbol

import * as task from "@rt/task";
or

Import directly with a jsr specifier

import * as task from "jsr:@rt/task";

Add Package

pnpm i jsr:@rt/task
or (using pnpm 10.8 or older)
pnpm dlx jsr add @rt/task

Import symbol

import * as task from "@rt/task";

Add Package

yarn add jsr:@rt/task
or (using Yarn 4.8 or older)
yarn dlx jsr add @rt/task

Import symbol

import * as task from "@rt/task";

Add Package

vlt install jsr:@rt/task

Import symbol

import * as task from "@rt/task";

Add Package

npx jsr add @rt/task

Import symbol

import * as task from "@rt/task";

Add Package

bunx jsr add @rt/task

Import symbol

import * as task from "@rt/task";