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

@danielpiva/platform

v0.0.3

Published

A 3,5kb standalone and dependency-free library that seemsly identifies the platform that your web app is running on.

Downloads

11

Readme

platform.js

A 3,5kb standalone and dependency-free library that seemsly identifies the platform that your web app is running on.

You can read this documentation in: Português Brasileiro.

Disclaimer: it was borrowed from Quasar Framework and adapted to work as standalone library.

Table of Contents

Installation

ES6 Example
import platform from '@danielpiva/platform/dist';

// Then you're good to go
console.log(platform.is.android);
Browser Example
<script src="https://unpkg.com/@danielpiva/platform@latest/dist/platform.min.js"></script>

<!-- 👉 Or you can just download the source code and host yourself -->

<script src="/path/to/@danielpiva/platform/dist/platform.min.js"></script>

<script>
  // Then you're good to go

  console.log(platform.is.android);
</script>

API

Note The only original feature missing is the parseSRR() method.

| Property | Type | Meaning | | --- | --- | --- | | platform.is.mobile | Boolean | Is the code running on a mobile device? | | platform.is.cordova | Boolean | Is the code running within Cordova? | | platform.is.electron | Boolean | Is the code running within Electron? | | platform.is.desktop | Boolean | Is the code running on a desktop browser? | | platform.is.chromeExt | Boolean | Is the code running is a Chrome extension environment? | | platform.has.touch | Boolean | Is the code running on a touch capable screen? | | platform.within.iframe | Boolean | Is the App running within an IFRAME? |

Note Running on mobile means you can have this code running on a mobile device (phone or tablet) but with a browser, not within a Cordova wrapper.

The platform.is object may have different properties based on the environment your web app is running on, such as:

| Property | | --- | | platform.is.ios| | platform.is.android| | platform.is.ipad | | platform.is.ipod | | platform.is.iphone | | platform.is.chrome | | platform.is.safari | | platform.is.opera | | platform.is.mac | | platform.is.win (Windows) | | platform.is.linux | | platform.is.cros | | platform.is.silk | | platform.is.kindle | | platform.is.blackberry | | platform.is.playbook | | platform.is.winphone (Windows Phone) | | And so on...|

Example when running Chrome on a Linux desktop machine:

// platform.is

{
  chrome: true,
  desktop: true,
  linux: true,
  name: "chrome",
  platform: "linux",
  version: "47.0.2526.80",
  versionNumber: 47,
  webkit: true
}

As a Vue JS 2 Plugin

@danielpiva/platform also works as Vue plugin out of the box.

ES6 Example
import Vue from 'vue';
import platform from 'platform';

Vue.use(platform);

new Vue({
  el: '#app',
  mounted() {

    // You may call this.$platform from anywhere inside of your component instances

    console.log(this.$platform);
  }
});
Browser Example
<script src="https://unpkg.com/vue@latest"></script>
<script src="https://unpkg.com/@danielpiva/platform@latest/dist/platform.min.js"></script>

<script>
  Vue.use(platform);

  new Vue({
    el: '#app',
    mounted() {

    // You may call this.$platform from anywhere inside of your component instances

    console.log(this.$platform);
  }
  });
</script>

Contributing

Anyone is welcome to suggest features, fix bugs by opening an issue or forking and submitting a pull request.

Author

Daniel Piva | [email protected]