Skip to content

Commit

Permalink
Merge pull request #1563 from ably/improve-platform-config-interface
Browse files Browse the repository at this point in the history
Improve IPlatformConfig
  • Loading branch information
VeskeR authored Jan 24, 2024
2 parents 9d33d7b + d41d61f commit 182f53d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/common/types/IPlatformConfig.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export interface IPlatformConfig {
/**
* Interface for common config properties shared between all platforms and that are relevant for all platforms.
*
* These properties must always be required and set for each platform.
*/
export interface ICommonPlatformConfig {
agent: string;
logTimestamps: boolean;
binaryType: BinaryType;
Expand All @@ -9,6 +14,14 @@ export interface IPlatformConfig {
nextTick: process.nextTick;
inspect: (value: unknown) => string;
stringByteSize: Buffer.byteLength;
}

/**
* Interface for platform specific config properties that do make sense on some platforms but not on others.
*
* These properties should always be optional, so that only relevant platforms would set them.
*/
export interface ISpecificPlatformConfig {
addEventListener?: typeof window.addEventListener | typeof global.addEventListener | null;
getRandomValues?: (arr: ArrayBufferView, callback?: (error: Error | null) => void) => void;
userAgent?: string | null;
Expand All @@ -29,3 +42,5 @@ export interface IPlatformConfig {
) => void;
isWebworker?: boolean;
}

export type IPlatformConfig = ICommonPlatformConfig & ISpecificPlatformConfig;

0 comments on commit 182f53d

Please sign in to comment.