Skip to content

Commit

Permalink
Add work utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Jan 18, 2023
1 parent 8308871 commit 7e7addc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/work.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { TaskContext } from "./task";
import { signalledPromise, timeoutPromise } from "./utils/promise";

export async function work<T>(context: TaskContext, promise: Promise<T>) {
return signalledPromise(context.signal, promise);
}

export async function timeout(context: TaskContext, ms: number) {
return work(context, timeoutPromise(ms));
}

0 comments on commit 7e7addc

Please sign in to comment.