Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve IPlatformConfig #1563

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading