electron-util
Version:
Useful utilities for Electron apps and modules
27 lines (25 loc) • 1.06 kB
TypeScript
import { type RequireAtLeastOne } from 'type-fest';
type _Choices<Macos, Windows, Linux, Default> = {
readonly macos?: Macos | (() => Macos);
readonly windows?: Windows | (() => Windows);
readonly linux?: Linux | (() => Linux);
readonly default?: Default | (() => Default);
};
export type Choices<Macos, Windows, Linux, Default> = RequireAtLeastOne<_Choices<Macos, Windows, Linux, Default>, 'macos' | 'windows' | 'linux'>;
/**
Accepts an object with the keys as either `macos`, `windows`, `linux`, or `default`, and picks the appropriate key depending on the current platform.
If no platform key is matched, the `default` key is used if it exists.
If the value is a function, it will be executed, and the returned value will be used.
@example
```
init({
enableUnicorn: util.platform({
macos: true,
windows: false,
linux: () => false
})
});
```
*/
export declare const platform: <Macos = never, Windows = never, Linux = never, Default = undefined>(choices: Choices<Macos, Windows, Linux, Default>) => any;
export {};