1.2.7 • Published 9 months ago

@alwatr/platform-info v1.2.7

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
9 months ago

Platform Info

This module provides a way to detect the current platform where the script is running. It defines a constant platformInfo which holds the information about the current platform.

PlatformInfo Object

The platformInfo constant object has the following properties:

  • name: The name of the current platform. It can be 'browser', 'node', 'semi-node', or 'unknown'.
  • development: A boolean indicating whether the NODE_ENV environment variable is not set to production or in browser location.hostname is localhost or 127.xxx.
  • isNode: A boolean indicating whether the current platform is node.js.
  • isBrowser: A boolean indicating whether the current platform is a browser.
  • isWebWorker: A boolean indicating whether the current platform is a web worker.
  • isDeno: A boolean indicating whether the current platform is Deno.
  • isNw: A boolean indicating whether the current platform is nw.js.
  • isElectron: A boolean indicating whether the current platform is Electron.

Development Mode Detection

The code also checks whether the script is running in development mode. If the script is running in a browser, it checks if the hostname is 'localhost' or 127.xxx. If the script is running in a 'semi-node' environment, it checks if the NODE_ENV environment variable is not set to 'production'. The result is stored in the development property of the platformInfo object.

Installation

yarn add @alwatr/platform-info

Usage

import {platformInfo} from '@alwatr/platform-info';

console.log(platformInfo.name); // 'browser' | 'node' | 'semi-node' | 'unknown'
console.log(platformInfo.development); // true | false
console.log(platformInfo.isNode); // true | false
console.log(platformInfo.isBrowser); // true | false
1.2.7

9 months ago

1.2.0

10 months ago

1.2.6

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.1.12

11 months ago

1.1.11

11 months ago

1.1.10

11 months ago

1.1.13

10 months ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago