Skip to content
1 min read · 87 words

Function: isolateFunction()

ts
function isolateFunction<A, R>(
  fn: (...args: A) => R | Promise<R>,
  options: IsolateFunctionOptions,
): IsolatedFunctionHandle<A, R>;

Defined in: src/batteries/isolation/isolate_function.ts:224

Run fn inside a throwaway, source-rehydrated Worker. See this module's doc comment for the full design and the trust-boundary implications of allowSourceRehydration.

Type Parameters

Type Parameter
A extends unknown[]
R

Parameters

ParameterType
fn(...args: A) => R | Promise<R>
optionsIsolateFunctionOptions

Returns

IsolatedFunctionHandle<A, R>

Throws

E_ISOLATE_FUNCTION_REQUIRES_SOURCE_REHYDRATION when allowSourceRehydration is not the literal true.