Skip to content

Commit

Permalink
chore: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Feb 7, 2023
1 parent 92ee01b commit 09e9fdb
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Executable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Promisable } from "type-fest";
import type { Promisable } from "type-fest";

/**
* The Runner interface.
Expand Down
2 changes: 1 addition & 1 deletion ExecutableWorker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { releaseProxy, Remote, UnproxyOrClone, wrap } from "comlink";
import { Promisable } from "type-fest";
import type { Promisable } from "type-fest";
import type { Executable } from "./Executable.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion Task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonValue } from "type-fest";
import type { JsonValue } from "type-fest";

export interface Task<TPayload = JsonValue> {
/**
Expand Down
2 changes: 1 addition & 1 deletion Workerpool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
assertSpyCalls,
spy,
} from "https://deno.land/[email protected]/testing/mock.ts";
import { Class, SetOptional } from "type-fest";
import type { Class, SetOptional } from "type-fest";
import { Executable } from "./Executable.ts";
import { ExecutableWorker } from "./ExecutableWorker.ts";
import { Task } from "./Task.ts";
Expand Down
10 changes: 6 additions & 4 deletions Workerpool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Class, JsonValue, Promisable, SetOptional } from "type-fest";
import type { Class, JsonValue, Promisable, SetOptional } from "type-fest";
import { Executable } from "./Executable.ts";
import { Runner, RunnerExecutionError } from "./Runner.ts";
import { Task } from "./Task.ts";
Expand Down Expand Up @@ -68,13 +68,15 @@ export type WorkerpoolOptions<TPayload = JsonValue, TResult = unknown> = {

/**
* Called when the state of the pool is changed.
* 1. **active:** Workerpool becomes active via .start() or .enqueue().
* 2. **draining:** Workerpool is paused via .pause().
* 3. **drained:** All active runners are disposed via task exhaustion or pausing.
*/
onStateChange?: (state: WorkerpoolState) => Promisable<void>;
};

/**
* 1. **running:** Workerpool becomes active via .start() or .enqueue().
* 2. **draining:** Workerpool is paused via .pause().
* 3. **drained:** All active runners are disposed via task exhaustion or pausing.
*/
export type WorkerpoolState = "running" | "draining" | "drained";

export class Workerpool<TPayload = JsonValue, TResult = unknown> {
Expand Down
3 changes: 1 addition & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"importMap": "./deno.json",
"imports": {
"comlink": "https://deno.land/x/[email protected]/mod.ts",
"type-fest": "https://deno.land/x/[email protected].6/mod.ts"
"type-fest": "https://deno.land/x/[email protected].7-alpha.2/mod.ts"
}
}
104 changes: 104 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09e9fdb

Please sign in to comment.