Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alwatr/platform-info

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alwatr/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.

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
465
increased by35.57%
Maintainers
0
Weekly downloads
 
Created
Source

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

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Exir Studio

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

License

This project is licensed under the AGPL-3.0 License.

Keywords

FAQs

Package last updated on 02 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc