# @phragon-util/global-var

> Helper for global variables (used on PhragonJS projects).

Latest version **0.0.2** (published 2023-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @phragon-util/global-var
pnpm add @phragon-util/global-var
yarn add @phragon-util/global-var
bun add @phragon-util/global-var
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-03-11 |
| First published | 2023-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | phragon@websoftlab.com |
| Maintainers | websoftlab |

## Links

- npm: https://www.npmjs.com/package/@phragon-util/global-var
- Repository: https://github.com/websoftlab/phragon-util
- Homepage: https://github.com/websoftlab/phragon-util#readme
- Issues: https://github.com/websoftlab/phragon-util/issues
- npm.io page: https://npm.io/package/@phragon-util/global-var

## Recent versions

- 0.0.2 (latest) — 2023-03-11
- 0.0.1 — 2023-03-08

## README

# @phragon-util/global-var

Helper for global variables (used on PhragonJS projects).

## ❯ Install

```
$ npm install --save @phragon-util/global-var
```

## All variables:

```typescript
// Environment Mode - Developer
const __DEV__: boolean;

// Environment Mode - Developer
// Script was run on the client-server side (Webpack)
const __DEV_SERVER__: boolean;

// Environment Mode - Production
const __PROD__: boolean;

// Bundle type
const __BUNDLE__: string;

// Server side rendering is used
const __SSR__: boolean;

// The script was run on the server side (backend)
const __SRV__: boolean;

// The script was run on the client side (front)
const __WEB__: boolean;

// Environment mode
const __ENV__: "production" | "development";
```

## Functions:

```typescript
import { defineGlobal, __isDev__, __isProd__, __isWeb__, __isSrv__, __env__ } from "@phragon-util/global-var";

// Define all global variables if they don't exist. 
// This function is automatically added to the PhragonJS build.
// Works only on the server side (NodeJS), in the client side the functions and the variables 
// will be removed and replaced with static values.
defineGlobal();

// Environment Mode - Developer
__isDev__();

// Environment Mode - Production
__isProd__();

// The script was run on the client side (front)
__isWeb__();

// The script was run on the server side (backend)
__isSrv__();

// Environment mode
__env__();
```

---
_Source: https://npm.io/package/@phragon-util/global-var · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
