procxy / isHandleSupported
Function: isHandleSupported()
ts
function isHandleSupported<T, H>(proxy): proxy is Procxy<T, "advanced", true>;Defined in: src/types/isomorphism.ts:384
Narrow a proxy's type to Procxy<T, 'advanced', true> when handle passing is enabled.
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", true>
true when $sendHandle is available on this proxy
Remarks
Calls the internal $isHandleSupported() method. Returns true only when the proxy was created with both serialization: 'advanced' and supportHandles: true. After narrowing, the $sendHandle method is available on the proxy type.
Example
typescript
import { procxy, isHandleSupported } from 'procxy';
import net from 'net';
import { SocketHandler } from './socket-handler.js';
const handler = await procxy(SocketHandler, {
serialization: 'advanced',
supportHandles: true
} as const);
if (isHandleSupported(handler)) {
// TypeScript knows $sendHandle is available
const socket = new net.Socket();
socket.connect(8080, 'localhost');
await handler.$sendHandle(socket);
}See
- isAdvancedMode — check serialization mode without handle support
- PassableHandle — types accepted by
$sendHandle