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

platform-detect

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

platform-detect - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

index.js

@@ -1,1 +0,1 @@

!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define("platform-detect",["exports"],o):o(e["platform-detect"]={})}(this,function(e){"use strict";function o(e,o){var n=window.matchMedia(e);o(n.matches);var i=()=>o(n.matches);return n.addListener(i),()=>n.removeListener(i)}function n(e,o){D[e]=D[e]||new Set,D[e].add(o)}function i(e,o){D[e]&&D[e].delete(o)}function t(e,o){D[e]&&D[e].forEach(e=>e(o))}function s(o){e.touch=o,e.mouse=!o,e.inputType=o?"touch":"mouse",e.tabletMode=o,t("inputType",e.inputType),t("tabletMode",e.tabletMode);var n=d();n!==e.formFactor&&(t("formFactor",e.formFactor),e.formFactor=n)}function d(){return c.includes("TV")?"tv":e.touch&&V<600?"phone":e.touch?"tablet":r?"laptop":"desktop"}if(e.hasWindow="undefined"!=typeof navigator&&"undefined"!=typeof window,e.hasWindow&&"undefined"!=typeof nw)try{nw.Window.get()}catch(o){e.hasWindow=!1}var r,a=!e.hasWindow,c=e.hasWindow?navigator.userAgent:void 0,u="undefined"!=typeof process&&!!process.versions&&!!process.versions.node,p=e.hasWindow&&window.matchMedia("(display-mode: standalone)").matches&&null!==document.head.querySelector('[rel="manifest"]'),l="undefined"!=typeof Windows&&"undefined"!=typeof MSApp,f=!(!u||!process.versions.nw),w=!(!u||!process.versions.electron),h=!(!e.hasWindow||!window.cordova),m=l||f||w||h||!1,v=!u&&!m,W=v&&!p,y=!e.hasWindow&&"undefined"!=typeof self&&void 0!==self.importScripts,g=y&&!!navigator.serviceWorker.controller,x=!!e.hasWindow&&c.includes("Android"),M=!!e.hasWindow&&c.includes("CrOS"),b=!!e.hasWindow&&c.includes("Tizen"),k=e.hasWindow&&/iPad|iPhone|iPod/.test(c)&&!window.MSStream||!1,S=x||b,P=u?"win32"===process.platform:c.includes("Windows"),F=u?"darwin"===process.platform:c.includes("Macintosh"),T=u?"linux"===process.platform:c.includes("Linux")&&!S,A=e.hasWindow&&c.includes("Edge/"),E=e.hasWindow&&c.includes("Chrome")&&!A,L=e.hasWindow&&c.includes("Safari")&&!E&&!A,O=e.hasWindow&&c.includes("Opera"),_=e.hasWindow&&c.includes("Firefox"),j=A,C=E,z=C||L,B=_,D={};if(e.hasWindow){e.pixelRatio=parseFloat(window.devicePixelRatio.toFixed(2)),e.touchscreen=navigator.maxTouchPoints>0;var N=window.screen.width,R=window.screen.height,V=Math.min(N,R);o("(orientation: portrait)",o=>{e.portrait=o;e.landscape=!o;e.orientation=o?"portrait":"landscape";t("orientation",e.orientation)}),A?s(e.touchscreen):o("(pointer: coarse)",s)}var q=l||!1;if(e.dev=!1,f)e.dev="sdk"===process.versions["nw-flavor"];else if(w)e.dev=process.execPath.replace(/\\/g,"/").includes("node_modules/electron/");else if(l)e.dev=Windows.ApplicationModel.Package.current.isDevelopmentMode;else if(v){let o=/./;o.toString=(()=>e.dev=!0),console.log("%c",o)}else u&&(e.dev="production"!==process.env.NODE_ENV);e.isConsole=a,e.ua=c,e.registerQuery=o,e.node=u,e.pwa=p,e.uwp=l,e.nwjs=f,e.electron=w,e.cordova=h,e.chromeapp=!1,e.packaged=m,e.web=v,e.website=W,e.worker=y,e.serviceWorker=g,e.android=x,e.chromeos=M,e.tizen=b,e.ios=k,e.linuxBased=S,e.windows=P,e.macos=F,e.linux=T,e.edge=A,e.chrome=E,e.safari=L,e.opera=O,e.firefox=_,e.edgeHtml=j,e.blink=C,e.webkit=z,e.gecko=B,e.on=n,e.removeListener=i,e.hasBattery=r,e.csp=q,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define("platform-detect",n):e["platform-detect"]=n()}(this,function(){"use strict";function e(e,n){var t=window.matchMedia(e);n(t.matches);var o=()=>n(t.matches);return t.addListener(o),()=>t.removeListener(o)}function n(e,n){Z[e]=Z[e]||new Set,Z[e].add(n)}function t(e,n){Z[e]&&Z[e].delete(n)}function o(e,n){Z[e]&&Z[e].forEach(e=>e(n))}function i(e){w=e,m=!e,g=e,o("inputType",p=e?"touch":"mouse"),o("tabletMode",g);var n=r();n!==u&&(o("formFactor",u),u=n)}function r(){return y.includes("TV")?"tv":w&&ne<600?"phone":w?"tablet":v?"laptop":"desktop"}var c="undefined"!=typeof navigator&&"undefined"!=typeof window;if(c&&"undefined"!=typeof nw)try{nw.Window.get()}catch(e){c=!1}var s,d,a,u,f,l,p,w,m,g,v,h=!c,y=c?navigator.userAgent:void 0,b=Object.freeze({get hasWindow(){return c},isConsole:h,ua:y,registerQuery:e}),x="undefined"!=typeof process&&!!process.versions&&!!process.versions.node,k=c&&window.matchMedia("(display-mode: standalone)").matches&&null!==document.head.querySelector('[rel="manifest"]'),O="undefined"!=typeof Windows&&"undefined"!=typeof MSApp,j=!(!x||!process.versions.nw),M=!(!x||!process.versions.electron),S=!(!c||!window.cordova),z=O||j||M||S||!1,P=!x&&!z,W=P&&!k,A=!c&&"undefined"!=typeof self&&void 0!==self.importScripts,E=A&&!!navigator.serviceWorker.controller,F=Object.freeze({node:x,pwa:k,uwp:O,nwjs:j,electron:M,cordova:S,chromeapp:!1,packaged:z,web:P,website:W,worker:A,serviceWorker:E}),L=!!c&&y.includes("Android"),T=!!c&&y.includes("CrOS"),C=!!c&&y.includes("Tizen"),B=c&&/iPad|iPhone|iPod/.test(y)&&!window.MSStream||!1,D=L||C,N=x?"win32"===process.platform:y.includes("Windows"),V=x?"darwin"===process.platform:y.includes("Macintosh"),_=x?"linux"===process.platform:y.includes("Linux")&&!D,q=Object.freeze({android:L,chromeos:T,tizen:C,ios:B,linuxBased:D,windows:N,macos:V,linux:_}),H=c&&y.includes("Edge/"),Q=c&&y.includes("Chrome")&&!H,R=c&&y.includes("Safari")&&!Q&&!H,G=c&&y.includes("Opera"),I=c&&y.includes("Firefox"),J=H,K=Q,U=K||R,X=I,Y=Object.freeze({edge:H,chrome:Q,safari:R,opera:G,firefox:I,edgeHtml:J,blink:K,webkit:U,gecko:X}),Z={};if(c){f=parseFloat(window.devicePixelRatio.toFixed(2)),l=navigator.maxTouchPoints>0;var $=window.screen.width,ee=window.screen.height,ne=Math.min($,ee);e("(orientation: portrait)",e=>{d=e;a=!e;s=e?"portrait":"landscape";o("orientation",s)}),H?i(l):e("(pointer: coarse)",i)}var te=Object.freeze({on:n,removeListener:t,get orientation(){return s},get portrait(){return d},get landscape(){return a},get formFactor(){return u},get pixelRatio(){return f},get touchscreen(){return l},get inputType(){return p},get touch(){return w},get mouse(){return m},get tabletMode(){return g},hasBattery:v}),oe=O||!1,ie=!1;if(j)ie="sdk"===process.versions["nw-flavor"];else if(M)ie=process.execPath.replace(/\\/g,"/").includes("node_modules/electron/");else if(O)ie=Windows.ApplicationModel.Package.current.isDevelopmentMode;else if(P){let e=/./;e.toString=(()=>ie=!0),console.log("%c",e)}else x&&(ie="production"!==process.env.NODE_ENV);var re=Object.freeze({csp:oe,get dev(){return ie}});return Object.assign({},b,F,q,Y,te,re)});
{
"name": "platform-detect",
"version": "1.1.0",
"version": "1.2.0",
"description": "🃏 Minimalistic isomorphic library for detection of platform, runtime, APIs and more.",

@@ -5,0 +5,0 @@ "author": "Mike Kovarik",

@@ -41,3 +41,3 @@ # platform-detect

```js
import * as platform from 'platform-detect'
import platform from 'platform-detect'

@@ -114,3 +114,3 @@

<script type="module">
import * as platform from './node_modules/platform-detect/index.js'
import platform from './node_modules/platform-detect/index.js'

@@ -124,2 +124,7 @@ platform.on('orientation', orientation => console.log(orientation))

[Check out the demo for full table of APIs](http://htmlpreview.github.io/?https://github.com/MikeKovarik/platform-detect/blob/master/example.html)
[Check out the demo for full table of APIs](http://htmlpreview.github.io/?https://github.com/MikeKovarik/platform-detect/blob/master/example.html)
## Ideas for the future
* battery (platform.hasBattery)
* battery saver mode (there's hardly any battery api, let alone battery saver in it)

Sorry, the diff of this file is not supported yet

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