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

platform

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

platform

A platform detection library that works on nearly all JavaScript platforms.

  • 1.3.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is platform?

The 'platform' npm package is a platform detection library that can be used to identify the operating system, browser, and engine of the platform on which the current script is running. It can be used in both browser and Node.js environments.

What are platform's main functionalities?

Operating System Detection

This feature allows you to detect the operating system of the user's device. The code sample demonstrates how to import the platform module and log the operating system information to the console.

const platform = require('platform');
console.log(platform.os);

Browser Detection

This feature enables you to detect the browser name and version. The code sample shows how to log the browser name and version to the console.

const platform = require('platform');
console.log(platform.name + ' ' + platform.version);

Engine Detection

This feature is used to detect the layout engine of the browser. The code sample illustrates how to log the layout engine information to the console.

const platform = require('platform');
console.log(platform.layout);

Device Detection

This feature allows you to detect the specific device (e.g., 'iPad', 'iPhone'). The code sample demonstrates how to log the device information to the console.

const platform = require('platform');
console.log(platform.product);

User-Agent Parsing

This feature provides a method to parse a user-agent string and extract detailed information about the platform. The code sample shows how to parse a user-agent string and log the resulting object.

const platform = require('platform');
const info = platform.parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64)');
console.log(info);

Other packages similar to platform

Keywords

FAQs

Package last updated on 04 Jul 2020

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