WorkerOptions
interface WorkerOptions {
deno?: boolean | {
}namespace?: boolean;
permissions?: "inherit" | "none" | {
};env?: "inherit" | boolean | string[];
hrtime?: "inherit" | boolean;
net?: "inherit" | boolean | string[];
ffi?: "inherit" | boolean | Array<string | URL>;
read?: "inherit" | boolean | Array<string | URL>;
run?: "inherit" | boolean | Array<string | URL>;
write?: "inherit" | boolean | Array<string | URL>;
}; §Properties
§
deno?: boolean | {
[src]namespace?: boolean;
permissions?: "inherit" | "none" | {
}env?: "inherit" | boolean | string[];
hrtime?: "inherit" | boolean;
net?: "inherit" | boolean | string[];
ffi?: "inherit" | boolean | Array<string | URL>;
read?: "inherit" | boolean | Array<string | URL>;
run?: "inherit" | boolean | Array<string | URL>;
write?: "inherit" | boolean | Array<string | URL>;
}; UNSTABLE: New API.
Set deno.namespace to true
to make Deno
namespace and all of its
methods available to the worker environment. Defaults to false
.
Configure deno.permissions options to change the level of access the worker will have. By default it will inherit the permissions of its parent thread. The permissions of a worker can't be extended beyond its parent's permissions reach.
- "inherit" will take the permissions of the thread the worker is created in
- You can disable/enable permissions all together by passing a boolean
- You can provide a list of routes relative to the file the worker is created in to limit the access of the worker (read/write permissions only)
Example:
// mod.ts
const worker = new Worker(
new URL("deno_worker.ts", import.meta.url).href, {
type: "module",
deno: {
namespace: true,
permissions: {
read: true,
},
},
}
);