From e6f3a18efdc962126e8e835cf173f656c1ccbbfa Mon Sep 17 00:00:00 2001 From: sadaf Date: Sun, 25 Feb 2024 04:11:20 +0530 Subject: [PATCH] feat: using enums instead of string for constants --- src/enums.ts | 22 ++++++++++++++++++++++ src/index.ts | 8 +++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/enums.ts diff --git a/src/enums.ts b/src/enums.ts new file mode 100644 index 0000000..252911b --- /dev/null +++ b/src/enums.ts @@ -0,0 +1,22 @@ +export enum MODE { + Window, + Browser, + Cloud, + Chrome +} + +export enum OS { + Linux, + Windows, + Darwin, + FreeBSD, + Unknown +} + +export enum ARCH { + x64, + Arm, + Itanium, + ia32, + Unknown +} diff --git a/src/index.ts b/src/index.ts index 13fe5dd..1d5b67a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,10 @@ +import { MODE, OS, ARCH } from './enums'; + declare global { interface Window { // --- globals --- /** Mode of the application: window, browser, cloud, or chrome */ - NL_MODE: string; + NL_MODE: MODE; /** Application port */ NL_PORT: number; /** Command-line arguments */ @@ -20,9 +22,9 @@ interface Window { /** Returns true if extensions are enabled */ NL_EXTENABLED: boolean; /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Unknown */ - NL_OS: string; + NL_OS: OS; /** CPU architecture: x64, arm, itanium, ia32, or unknown */ - NL_ARCH: string; + NL_ARCH: ARCH; /** Neutralinojs server version */ NL_VERSION: string; /** Current working directory */