procxy / isAdvancedMode
Function: isAdvancedMode()
ts
function isAdvancedMode<T, H>(proxy): proxy is Procxy<T, "advanced", H>;Defined in: src/types/isomorphism.ts:340
Narrow a proxy's type to Procxy<T, 'advanced', H> at runtime.
Type Parameters
| Type Parameter |
|---|
T |
H extends boolean |
Parameters
| Parameter | Type | Description |
|---|---|---|
proxy | Procxy<T, any, H> | Any Procxy instance |
Returns
proxy is Procxy<T, "advanced", H>
true when the proxy was spawned with serialization: 'advanced'
Remarks
Calls the internal $getSerializationMode() method that every proxy exposes. If the proxy was created with serialization: 'advanced', this returns true and the TypeScript type is narrowed accordingly — useful when you receive a Procxy<T, any, H> and need to call a method that only accepts advanced-mode proxies.
Example
typescript
import { procxy, isAdvancedMode } from 'procxy';
import { Worker } from './worker.js';
const w = await procxy(Worker, { serialization: 'advanced' } as const);
if (isAdvancedMode(w)) {
// TypeScript now knows w is Procxy<Worker, 'advanced', false>
console.log('Can send Buffers');
}See
- isProcxy — check whether any value is a proxy at all
- isHandleSupported — check whether the proxy can send OS handles