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

current-device

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

current-device - npm Package Compare versions

Comparing version 0.6.3 to 0.7.0

40

es/index.js

@@ -9,3 +9,3 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent;
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList;

@@ -17,2 +17,4 @@ // Save the previous value of the device variable.

changeOrientationList = [];
// Add device as a global object.

@@ -249,12 +251,27 @@ window.device = device;

addClass("landscape");
walkOnChangeOrientationList("landscape");
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
}
setOrientationCache();
};
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
}
};
// Detect whether device supports orientationchange event,
// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "orientationchange";
orientationEvent = "onorientationchange";
} else {

@@ -275,2 +292,21 @@ orientationEvent = "resize";

// Public functions to get the current value of type, os, or orientation
// ---------------------------------------------------------------------
function findMatch(arr) {
for (var i = 0; i < arr.length; i++) {
if (device[arr[i]]()) {
return arr[i];
}
}
return 'unknown';
}
device.type = findMatch(['mobile', 'tablet', 'desktop']);
device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();
export default device;

@@ -13,3 +13,3 @@ 'use strict';

var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent;
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList;

@@ -21,2 +21,4 @@ // Save the previous value of the device variable.

changeOrientationList = [];
// Add device as a global object.

@@ -253,12 +255,27 @@ window.device = device;

addClass("landscape");
walkOnChangeOrientationList("landscape");
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
}
setOrientationCache();
};
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
}
};
// Detect whether device supports orientationchange event,
// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "orientationchange";
orientationEvent = "onorientationchange";
} else {

@@ -279,3 +296,22 @@ orientationEvent = "resize";

// Public functions to get the current value of type, os, or orientation
// ---------------------------------------------------------------------
function findMatch(arr) {
for (var i = 0; i < arr.length; i++) {
if (device[arr[i]]()) {
return arr[i];
}
}
return 'unknown';
}
device.type = findMatch(['mobile', 'tablet', 'desktop']);
device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();
exports.default = device;
module.exports = exports['default'];
{
"name": "current-device",
"version": "0.6.3",
"version": "0.7.0",
"homepage": "https://github.com/matthewhudson/current-device",

@@ -90,2 +90,6 @@ "description": "The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo, AppleTV, etc), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).",

"url": "http://eswat.ca"
},
{
"name": "Mustard Andrew",
"email": "mustard.andrew@gmail.com"
}

@@ -92,0 +96,0 @@ ],

/*!
* current-device v0.6.2 - https://github.com/matthewhudson/current-device
* current-device v0.6.3 - https://github.com/matthewhudson/current-device
* MIT Licensed

@@ -101,3 +101,3 @@ */

var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent;
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList;

@@ -109,2 +109,4 @@ // Save the previous value of the device variable.

changeOrientationList = [];
// Add device as a global object.

@@ -341,12 +343,27 @@ window.device = device;

addClass("landscape");
walkOnChangeOrientationList("landscape");
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
}
setOrientationCache();
};
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
}
};
// Detect whether device supports orientationchange event,
// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "orientationchange";
orientationEvent = "onorientationchange";
} else {

@@ -367,2 +384,21 @@ orientationEvent = "resize";

// Public functions to get the current value of type, os, or orientation
// ---------------------------------------------------------------------
function findMatch(arr) {
for (var i = 0; i < arr.length; i++) {
if (device[arr[i]]()) {
return arr[i];
}
}
return 'unknown';
}
device.type = findMatch(['mobile', 'tablet', 'desktop']);
device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();
/* harmony default export */ __webpack_exports__["default"] = (device);

@@ -369,0 +405,0 @@

4

umd/current-device.min.js
/*!
* current-device v0.6.2 - https://github.com/matthewhudson/current-device
* current-device v0.6.3 - https://github.com/matthewhudson/current-device
* MIT Licensed
*/
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.device=n():e.device=n()}(this,function(){return function(e){function n(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var o={};return n.m=e,n.c=o,n.d=function(e,o,t){n.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(o,"a",o),o},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,o){e.exports=o(1)},function(e,n,o){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t,r,i,a,d,c,u,l,s,b,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r=window.device,t={},window.device=t,a=window.document.documentElement,b=window.navigator.userAgent.toLowerCase(),t.macos=function(){return d("mac")},t.ios=function(){return t.iphone()||t.ipod()||t.ipad()},t.iphone=function(){return!t.windows()&&d("iphone")},t.ipod=function(){return d("ipod")},t.ipad=function(){return d("ipad")},t.android=function(){return!t.windows()&&d("android")},t.androidPhone=function(){return t.android()&&d("mobile")},t.androidTablet=function(){return t.android()&&!d("mobile")},t.blackberry=function(){return d("blackberry")||d("bb10")||d("rim")},t.blackberryPhone=function(){return t.blackberry()&&!d("tablet")},t.blackberryTablet=function(){return t.blackberry()&&d("tablet")},t.windows=function(){return d("windows")},t.windowsPhone=function(){return t.windows()&&d("phone")},t.windowsTablet=function(){return t.windows()&&d("touch")&&!t.windowsPhone()},t.fxos=function(){return(d("(mobile;")||d("(tablet;"))&&d("; rv:")},t.fxosPhone=function(){return t.fxos()&&d("mobile")},t.fxosTablet=function(){return t.fxos()&&d("tablet")},t.meego=function(){return d("meego")},t.cordova=function(){return window.cordova&&"file:"===location.protocol},t.nodeWebkit=function(){return"object"===f(window.process)},t.mobile=function(){return t.androidPhone()||t.iphone()||t.ipod()||t.windowsPhone()||t.blackberryPhone()||t.fxosPhone()||t.meego()},t.tablet=function(){return t.ipad()||t.androidTablet()||t.blackberryTablet()||t.windowsTablet()||t.fxosTablet()},t.desktop=function(){return!t.tablet()&&!t.mobile()},t.television=function(){var e,n=["googletv","viera","smarttv","internet.tv","netcast","nettv","appletv","boxee","kylo","roku","dlnadoc","roku","pov_tv","hbbtv","ce-html"];for(e=0;e<n.length;){if(d(n[e]))return!0;e++}return!1},t.portrait=function(){return window.innerHeight/window.innerWidth>1},t.landscape=function(){return window.innerHeight/window.innerWidth<1},t.noConflict=function(){return window.device=r,this},d=function(e){return-1!==b.indexOf(e)},u=function(e){var n;return n=new RegExp(e,"i"),a.className.match(n)},i=function(e){var n=null;u(e)||(n=a.className.replace(/^\s+|\s+$/g,""),a.className=n+" "+e)},s=function(e){u(e)&&(a.className=a.className.replace(" "+e,""))},t.ios()?t.ipad()?i("ios ipad tablet"):t.iphone()?i("ios iphone mobile"):t.ipod()&&i("ios ipod mobile"):t.macos()?i("macos desktop"):t.android()?i(t.androidTablet()?"android tablet":"android mobile"):t.blackberry()?i(t.blackberryTablet()?"blackberry tablet":"blackberry mobile"):t.windows()?i(t.windowsTablet()?"windows tablet":t.windowsPhone()?"windows mobile":"windows desktop"):t.fxos()?i(t.fxosTablet()?"fxos tablet":"fxos mobile"):t.meego()?i("meego mobile"):t.nodeWebkit()?i("node-webkit"):t.television()?i("television"):t.desktop()&&i("desktop"),t.cordova()&&i("cordova"),c=function(){t.landscape()?(s("portrait"),i("landscape")):(s("landscape"),i("portrait"))},l=Object.prototype.hasOwnProperty.call(window,"onorientationchange")?"orientationchange":"resize",window.addEventListener?window.addEventListener(l,c,!1):window.attachEvent?window.attachEvent(l,c):window[l]=c,c(),n.default=t}])});
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.device=e():n.device=e()}(this,function(){return function(n){function e(t){if(o[t])return o[t].exports;var i=o[t]={i:t,l:!1,exports:{}};return n[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var o={};return e.m=n,e.c=o,e.d=function(n,o,t){e.o(n,o)||Object.defineProperty(n,o,{configurable:!1,enumerable:!0,get:t})},e.n=function(n){var o=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(o,"a",o),o},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=0)}([function(n,e,o){n.exports=o(1)},function(n,e,o){"use strict";function t(n){for(var e=0;e<n.length;e++)if(r[n[e]]())return n[e];return"unknown"}function i(){r.orientation=t(["portrait","landscape"])}Object.defineProperty(e,"__esModule",{value:!0});var r,a,d,c,u,l,s,f,b,p,w,m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};a=window.device,r={},w=[],window.device=r,c=window.document.documentElement,p=window.navigator.userAgent.toLowerCase(),r.macos=function(){return u("mac")},r.ios=function(){return r.iphone()||r.ipod()||r.ipad()},r.iphone=function(){return!r.windows()&&u("iphone")},r.ipod=function(){return u("ipod")},r.ipad=function(){return u("ipad")},r.android=function(){return!r.windows()&&u("android")},r.androidPhone=function(){return r.android()&&u("mobile")},r.androidTablet=function(){return r.android()&&!u("mobile")},r.blackberry=function(){return u("blackberry")||u("bb10")||u("rim")},r.blackberryPhone=function(){return r.blackberry()&&!u("tablet")},r.blackberryTablet=function(){return r.blackberry()&&u("tablet")},r.windows=function(){return u("windows")},r.windowsPhone=function(){return r.windows()&&u("phone")},r.windowsTablet=function(){return r.windows()&&u("touch")&&!r.windowsPhone()},r.fxos=function(){return(u("(mobile;")||u("(tablet;"))&&u("; rv:")},r.fxosPhone=function(){return r.fxos()&&u("mobile")},r.fxosTablet=function(){return r.fxos()&&u("tablet")},r.meego=function(){return u("meego")},r.cordova=function(){return window.cordova&&"file:"===location.protocol},r.nodeWebkit=function(){return"object"===m(window.process)},r.mobile=function(){return r.androidPhone()||r.iphone()||r.ipod()||r.windowsPhone()||r.blackberryPhone()||r.fxosPhone()||r.meego()},r.tablet=function(){return r.ipad()||r.androidTablet()||r.blackberryTablet()||r.windowsTablet()||r.fxosTablet()},r.desktop=function(){return!r.tablet()&&!r.mobile()},r.television=function(){var n,e=["googletv","viera","smarttv","internet.tv","netcast","nettv","appletv","boxee","kylo","roku","dlnadoc","roku","pov_tv","hbbtv","ce-html"];for(n=0;n<e.length;){if(u(e[n]))return!0;n++}return!1},r.portrait=function(){return window.innerHeight/window.innerWidth>1},r.landscape=function(){return window.innerHeight/window.innerWidth<1},r.noConflict=function(){return window.device=a,this},u=function(n){return-1!==p.indexOf(n)},s=function(n){var e;return e=new RegExp(n,"i"),c.className.match(e)},d=function(n){var e=null;s(n)||(e=c.className.replace(/^\s+|\s+$/g,""),c.className=e+" "+n)},b=function(n){s(n)&&(c.className=c.className.replace(" "+n,""))},r.ios()?r.ipad()?d("ios ipad tablet"):r.iphone()?d("ios iphone mobile"):r.ipod()&&d("ios ipod mobile"):r.macos()?d("macos desktop"):r.android()?d(r.androidTablet()?"android tablet":"android mobile"):r.blackberry()?d(r.blackberryTablet()?"blackberry tablet":"blackberry mobile"):r.windows()?d(r.windowsTablet()?"windows tablet":r.windowsPhone()?"windows mobile":"windows desktop"):r.fxos()?d(r.fxosTablet()?"fxos tablet":"fxos mobile"):r.meego()?d("meego mobile"):r.nodeWebkit()?d("node-webkit"):r.television()?d("television"):r.desktop()&&d("desktop"),r.cordova()&&d("cordova"),l=function(){r.landscape()?(b("portrait"),d("landscape"),walkOnChangeOrientationList("landscape")):(b("landscape"),d("portrait"),walkOnChangeOrientationList("portrait")),i()},walkOnChangeOrientationList=function(n){for(var e in w)w[e](n)},r.onChangeOrientation=function(n){"function"==typeof n&&w.push(n)},f=Object.prototype.hasOwnProperty.call(window,"onorientationchange")?"onorientationchange":"resize",window.addEventListener?window.addEventListener(f,l,!1):window.attachEvent?window.attachEvent(f,l):window[f]=l,l(),r.type=t(["mobile","tablet","desktop"]),r.os=t(["ios","iphone","ipad","ipod","android","blackberry","windows","fxos","meego","television"]),i(),e.default=r}])});
//# sourceMappingURL=current-device.min.js.map

Sorry, the diff of this file is not supported yet

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