satisfy export-docs

This commit is contained in:
Anton Nesterov 2024-10-25 23:31:12 +02:00
parent 76541535e4
commit 27ce25096d
No known key found for this signature in database
GPG key ID: 59121E8AE2851FB5
7 changed files with 16 additions and 6 deletions

View file

@ -142,7 +142,5 @@ function withMessageInterceptor(worker) {
export {
offload,
handler,
createPooledCallback,
createBufferedCallback,
OffloadError
};

View file

@ -1,5 +1,5 @@
{
"name": "@nesterow/offload",
"version": "0.0.1",
"version": "0.0.2",
"exports": "./mod.ts"
}

View file

@ -1,3 +1,6 @@
/**
* OffloadError class
*/
export class OffloadError extends Error {
constructor(message: string, options?: any) {
super(message, options);

View file

@ -4,6 +4,9 @@ declare var self: Worker;
type HandlerCallback<T, E> = ((data: E) => T) | ((data: E) => Awaited<T>);
/**
* Handler wraps a callback function to be used as a worker handler
*/
export async function handler<T, E>(fn: HandlerCallback<T, E>): Promise<void> {
self.addEventListener("message", async (event) => {
const request = event.data as WorkerRequest<E>;

View file

@ -1,2 +1,8 @@
/**
* Response from a worker
*/
export type WorkerResponse<T> = { id: number; value: T };
/**
* Request to a worker
*/
export type WorkerRequest<T> = { id: number; params: T };

View file

@ -82,7 +82,7 @@ function createTaskCallback<T, E>(
return cb;
}
export function createBufferedCallback<T, E>(
function createBufferedCallback<T, E>(
bufSize: number,
fun: () => TaskCallback<T, E>,
): [Callback<T, E>, Terminator] {
@ -112,7 +112,7 @@ export function createBufferedCallback<T, E>(
return [call, term];
}
export function createPooledCallback<T, E>(
function createPooledCallback<T, E>(
poolSize: number,
fun: () => TaskCallback<T, E>,
): [Callback<T, E>, Terminator] {

View file

@ -1,6 +1,6 @@
{
"name": "@nesterow/offload",
"version": "0.0.1",
"version": "0.0.2",
"author": {
"name": "Anton Nesterov",
"url": "https://github.com/nesterow"