@ably/chat
Version:
Ably Chat is a set of purpose-built APIs for a host of chat features enabling you to create 1:1, 1:Many, Many:1 and Many:Many chat rooms for any scale. It is designed to meet a wide range of chat use cases, such as livestreams, in-game communication, cust
22 lines (19 loc) • 716 B
text/typescript
import * as Ably from 'ably';
import { ErrorCode } from './errors.js';
/**
* Asserts that a serial parameter is valid (not undefined, null, or empty string).
* @internal
* @param serial The serial value to validate.
* @param op The operation being performed (e.g., "send message reaction").
* @param paramName The name of the parameter (e.g., "messageSerial").
* @throws {Ably.ErrorInfo} With InvalidArgument code if the serial is invalid.
*/
export const assertValidSerial = (serial: unknown, op: string, paramName: string): void => {
if (!serial) {
throw new Ably.ErrorInfo(
`unable to ${op}; ${paramName} must be a non-empty string`,
ErrorCode.InvalidArgument,
400,
);
}
};