Skip to content

Commit

Permalink
chore: run autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonOehlman committed Jun 16, 2020
1 parent d7127aa commit 52f4239
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
export type DetectedInfoType = 'browser' | 'node' | 'bot-device' | 'bot' | 'react-native';
export type DetectedInfoType =
| 'browser'
| 'node'
| 'bot-device'
| 'bot'
| 'react-native';

interface DetectedInfo<
T extends DetectedInfoType,
N extends string,
O,
V = null
> {
> {
readonly type: T;
readonly name: N;
readonly version: V;
Expand All @@ -19,7 +24,7 @@ export class BrowserInfo
public readonly name: Browser,
public readonly version: string,
public readonly os: OperatingSystem | null,
) { }
) {}
}

export class NodeInfo
Expand All @@ -28,19 +33,19 @@ export class NodeInfo
public readonly name: 'node' = 'node';
public readonly os: NodeJS.Platform = process.platform;

constructor(public readonly version: string) { }
constructor(public readonly version: string) {}
}

export class SearchBotDeviceInfo
implements
DetectedInfo<'bot-device', Browser, OperatingSystem | null, string> {
DetectedInfo<'bot-device', Browser, OperatingSystem | null, string> {
public readonly type = 'bot-device';
constructor(
public readonly name: Browser,
public readonly version: string,
public readonly os: OperatingSystem | null,
public readonly bot: string,
) { }
) {}
}

export class BotInfo implements DetectedInfo<'bot', 'bot', null, null> {
Expand All @@ -57,7 +62,7 @@ export class ReactNativeInfo
public readonly name: 'react-native' = 'react-native';
public readonly version: null = null;
public readonly os: null = null;
};
}

export type Browser =
| 'aol'
Expand Down Expand Up @@ -188,7 +193,13 @@ const operatingSystemRules: OperatingSystemRule[] = [

export function detect(
userAgent?: string,
): BrowserInfo | SearchBotDeviceInfo | BotInfo | NodeInfo | ReactNativeInfo | null {
):
| BrowserInfo
| SearchBotDeviceInfo
| BotInfo
| NodeInfo
| ReactNativeInfo
| null {
if (!!userAgent) {
return parseUserAgent(userAgent);
}
Expand Down

0 comments on commit 52f4239

Please sign in to comment.