包详细信息

@alwatr/platform-info

Alwatr6.5kMPL-2.05.5.20

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.

alwatr, browser, cross-platform, deno

自述文件

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.

Contributing

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

更新日志

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.5.20 (2025-10-06)

🔗 Dependencies update

  • bump the npm-dependencies group with 4 updates (9825815)

5.5.19 (2025-09-27)

🧹 Miscellaneous Chores

  • exclude test files from package distribution (86f4f2f)

5.5.18 (2025-09-22)

Note: Version bump only for package @alwatr/platform-info

5.5.17 (2025-09-22)

Note: Version bump only for package @alwatr/platform-info

5.5.16 (2025-09-21)

Note: Version bump only for package @alwatr/platform-info

5.5.15 (2025-09-20)

🐛 Bug Fixes

  • add sideEffects property to package.json files for better tree-shaking (c7b9e74)
  • add sideEffects property to package.json files for better tree-shaking (e8402c4)
  • remove unnecessary pure annotations (adeb916)

🧹 Miscellaneous Chores

  • remove duplicate sideEffects property from multiple package.json files (b123f86)

5.5.14 (2025-09-19)

Note: Version bump only for package @alwatr/platform-info

5.5.13 (2025-09-15)

Note: Version bump only for package @alwatr/platform-info

5.5.12 (2025-09-13)

🔗 Dependencies update

  • update @types/node version to ^22.18.3 in multiple package.json files (13db6fc)

5.5.11 (2025-09-13)

🧹 Miscellaneous Chores

  • remove package-tracer dependency and related code from fetch package (96fe4e9)
  • remove package-tracer dependency and related code from platform-info (ac93d49)

5.5.10 (2025-09-09)

🧹 Miscellaneous Chores

  • remove trailing newlines from contributing sections in README files (e8ab1bc)

5.5.9 (2025-09-06)

Note: Version bump only for package @alwatr/platform-info

5.5.8 (2025-09-05)

🔗 Dependencies update

  • update jest to version 30.1.3 and @types/node to version 22.18.1 (754212b)

5.5.7 (2025-09-01)

🔗 Dependencies update

  • update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 (95d7870)

5.5.6 (2025-08-23)

Note: Version bump only for package @alwatr/platform-info

5.5.5 (2025-08-23)

🐛 Bug Fixes

  • update license from AGPL-3.0-only to MPL-2.0 (d20968e)
  • update package versions in multiple package.json files (7638b1c)

🔨 Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7)

🧹 Miscellaneous Chores

  • reformat all package.json files (ceda45d)

🔗 Dependencies update

  • revert @types/node version to ^22.17.2 (LTS) (49f8101)
  • update TypeScript and Jest versions across all packages to improve compatibility and performance (31baf36)

5.5.4 (2025-08-23)

Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7) by @alimd

5.5.3 (2025-04-15)

Note: Version bump only for package @alwatr/platform-info

5.5.2 (2025-04-01)

Dependencies update

  • bump the development-dependencies group across 1 directory with 2 updates (c1320b4) by @dependabot[bot]

5.5.1 (2025-03-18)

Dependencies update

  • bump the development-dependencies group with 9 updates (7290aa3) by @dependabot[bot]

5.5.0 (2025-03-06)

Miscellaneous Chores

  • update username casing in changelog entries (9722ac9) by @

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (720c395) by @dependabot[bot]

5.4.0 (2025-02-18)

Dependencies update

  • bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 (b9a8399) by @

5.3.0 (2025-02-03)

Miscellaneous Chores

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.

Code Refactoring

  • use the same version as @alwatr/nanolib (60eb860) by @

5.3.0 (2025-02-03)

Miscellaneous Chores

  • edit README (3860b3d) by @ArmanAsadian

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @dependabot[bot]
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @alimd

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.

Features

  • platform-info: Add isWebWorker property to platformInfo constant object (ae3ca10) by @
  • platform-info: new package for detect the current platform (83f9534) by @
  • platform-info: support bun and isCli (d693067) by @
  • use package-tracer (cc3c5f9) by @

Bug Fixes

  • all dependeny topology (1c17f34) by @
  • platform-info: Update platformInfo logic and remove redundant code for prevent side-effects (db46c48) by @
  • tsBuildInfoFile path in tsconfig.json files (9c4ba01) by @
  • update to latest nano-build with preset (a4d3c35) by @

Code Refactoring

  • platform-info: enhance type to prevent modification (e62c0eb) by @
  • prevent side-effects (01e00e1) by @
  • use new type-helper global types and remove all import types (08b5d08) by @
  • use the same version as @alwatr/nanolib (60eb860) by @

Miscellaneous Chores

  • deps-dev: bump the development-dependencies group with 3 updates (0e0ec0f) by @
  • deps-dev: bump the development-dependencies group with 3 updates (e0cf373) by @
  • deps: update (1a45030) by @
  • deps: update (8e70dff) by @
  • deps: update (f0b60d2) by @
  • include LICENSE and LEGAL files to publish (09f366f) by @
  • platform-info: change the license to AGPL-3.0 (0ca6ad1) by @
  • rename logger env (38443ad) by @
  • Update build and lint scripts (392d0b7) by @
  • update clean script to remove all .tsbuildinfo files (91f1ff2) by @
  • Update debug command in package.json (be8403d) by @
  • Update package.json exports for @alwatr packages (dacb362) by @

Dependencies update

  • bump @types/node (3d80fed) by @
  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @
  • bump the development-dependencies group across 1 directory with 2 updates (2dfda9e) by @
  • bump the development-dependencies group with 10 updates (fa4aaf0) by @
  • bump the development-dependencies group with 2 updates (be5d6c2) by @
  • bump the development-dependencies group with 8 updates (16847ac) by @
  • upd (451d025) by @
  • update (4434ba6) by @
  • update (c36ed50) by @
  • update all (53342f6) by @
  • update all dependencies (1e0c30e) by @
  • update all dependencies (0e908b4) by @
  • upgrade (6dbd300) by @

1.2.8 (2024-11-02)

Dependencies update

1.2.7 (2024-10-25)

Dependencies update

  • bump the development-dependencies group across 1 directory with 2 updates (2dfda9e) by @dependabot[bot]
  • bump the development-dependencies group with 8 updates (16847ac) by @dependabot[bot]

1.2.6 (2024-10-12)

Note: Version bump only for package @alwatr/platform-info

1.2.5 (2024-10-11)

Bug Fixes

  • platform-info: Update platformInfo logic and remove redundant code for prevent side-effects (db46c48) by @alimd

Code Refactoring

  • prevent side-effects (01e00e1) by @mohammadhonarvar

1.2.4 (2024-10-11)

Miscellaneous Chores

  • include LICENSE and LEGAL files to publish (09f366f) by @alimd

1.2.3 (2024-10-11)

Note: Version bump only for package @alwatr/platform-info

1.2.2 (2024-10-10)

Dependencies update

  • bump the development-dependencies group with 10 updates (fa4aaf0) by @dependabot[bot]

1.2.1 (2024-10-08)

Note: Version bump only for package @alwatr/platform-info

1.2.0 (2024-09-29)

Features

  • use package-tracer (cc3c5f9) by @mohammadhonarvar

Bug Fixes

  • all dependeny topology (1c17f34) by @mohammadhonarvar

Code Refactoring

  • platform-info: enhance type to prevent modification (e62c0eb) by @alimd
  • use new type-helper global types and remove all import types (08b5d08) by @alimd

Miscellaneous Chores

  • platform-info: change the license to AGPL-3.0 (0ca6ad1) by @ArmanAsadian
  • Update build and lint scripts (392d0b7) by @alimd

Dependencies update

  • bump @types/node (3d80fed) by @dependabot[bot]

1.1.13 (2024-09-21)

Note: Version bump only for package @alwatr/platform-info

1.1.12 (2024-09-15)

Dependencies update

  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @dependabot[bot]
  • update (c36ed50) by @alimd

1.1.11 (2024-08-31)

Miscellaneous Chores

1.1.10 (2024-08-31)

Dependencies update

  • update all dependencies (1e0c30e) by @alimd

1.1.9 (2024-07-04)

Dependencies update

  • update all dependencies (0e908b4) by @

1.1.8 (2024-05-12)

Dependencies update

1.1.7 (2024-04-25)

Note: Version bump only for package @alwatr/platform-info

1.1.6 (2024-03-28)

Note: Version bump only for package @alwatr/platform-info

1.1.5 (2024-01-31)

Miscellaneous Chores

1.1.4 (2024-01-24)

Note: Version bump only for package @alwatr/platform-info

1.1.3 (2024-01-20)

Note: Version bump only for package @alwatr/platform-info

1.1.2 (2024-01-16)

Note: Version bump only for package @alwatr/platform-info

1.1.1 (2024-01-08)

Note: Version bump only for package @alwatr/platform-info

1.1.0 (2024-01-03)

Features

  • platform-info: support bun and isCli (d693067) by @njfamirm

1.0.7 (2024-01-03)

Note: Version bump only for package @alwatr/platform-info

1.0.6 (2023-12-26)

Note: Version bump only for package @alwatr/platform-info

1.0.5 (2023-12-26)

Note: Version bump only for package @alwatr/platform-info

1.0.4 (2023-12-23)

Bug Fixes

  • tsBuildInfoFile path in tsconfig.json files (9c4ba01) by @

1.0.3 (2023-12-23)

Note: Version bump only for package @alwatr/platform-info

1.0.2 (2023-12-23)

Note: Version bump only for package @alwatr/platform-info

1.0.1 (2023-12-23)

Bug Fixes

  • update to latest nano-build with preset (a4d3c35) by @

1.0.0 (2023-12-22)

Features

  • platform-info: Add isWebWorker property to platformInfo constant object (ae3ca10) by @
  • platform-info: new package for detect the current platform (83f9534) by @alimd