UNPKG

@nestjs/websockets

Version:

Nest - modern, fast, powerful node.js web framework (@websockets)

21 lines (20 loc) 610 B
import { WsParamtype } from '../enums/ws-paramtype.enum.js'; import { isFunction } from '@nestjs/common/internal'; export class WsParamsFactory { exchangeKeyForValue(type, data, args) { if (!args) { return null; } switch (type) { case WsParamtype.SOCKET: return args[0]; case WsParamtype.PAYLOAD: return data ? args[1]?.[data] : args[1]; case WsParamtype.ACK: { return args.find(arg => isFunction(arg)); } default: return null; } } }