npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-device-info

v1.2.0

Published

Find out execution device info, e.g. if executing device has DOM available, or is mobile, tablet or desktop device. Customizable using environment variables.

Downloads

6

Readme

web-device-info

Find out execution device info, e.g. if executing device has DOM available, or is mobile, tablet or desktop device. Customizable using environment variables.

If using yarn:

yarn add web-device-info

If using npm:

npm install web-device-info

To use in code:

  • canUseDOM is a variable which is true if execution device has DOM available.

Declare import { canUseDOM } from 'web-device-info'

Then in code:

if ( canUseDOM ) {}

  • isMobileScreenSize() is a function which takes optional isMobileScreenSize check breakpoint. It tells whether execution device current window size is in mobile view range or not.

Declare import { isMobileScreenSize, isTabletScreenSize, isDesktopScreenSize } from 'web-device-info'

Then in code:

if ( isMobileScreenSize(768) ) {}

  • isMobile is a variable which returns if execution device is mobile or not.

Declare import { isMobile, isIOS, isMac, isWindows, isLinux } from 'web-device-info'

Then in code:

if ( isMobile ) {}

May support ES5 environment also.

Default device check conditions:

  • Mobile < 768px
  • >= 768px Tablet <= 1024px
  • > 1024px Desktop <= 1200px
  • > 1200px Large desktop
  • > 1440px Extra large desktop

Customization of default using environment variables (e.g. can be set in .env files in React)

  • RESPONSIVE_STRATEGY = 'mobile_first' Default value = 'desktop_first' Possible values are 'mobile_first', 'desktop_first' or 'table_first'

  • LARGE_DESKTOP_BREAKPOINT = 1440

  • DESKTOP_BREAKPOINT = 1200

  • TABLET_BREAKPOINT = 1024

  • MOBILE_BREAKPOINT = 768

Editor Configuration

  • Editor of your preference. I used some VSCode specific config in .vscode folder and recommend plugins for enhanced experience.

Recommended VSCode Extensions:

  • Prettier (Official) - Code formatter
  • ESLint (Official) - Real time JS syntax validation

Technologies Used

Available Scripts [For development]

In the project directory, you can run:

yarn build

To build the project

yarn watch

To build with livereload

yarn fix:all

Runs prettier formatter followed by eslint, to format code and fix lint issues. Prettier is not good enough to run alone, must always be followed lint fixes included in this command.