Socket
Socket
Sign inDemoInstall

is-mobile

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-mobile - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

1

index.d.ts

@@ -15,4 +15,5 @@ interface HttpRequestHeadersInterfaceMock {

tablet?: boolean
featureDetect?: boolean
}
export declare function isMobile(opts?:IsMobileOptions): boolean;

@@ -20,3 +20,17 @@ 'use strict'

return opts.tablet ? tabletRE.test(ua) : mobileRE.test(ua)
var result = opts.tablet ? tabletRE.test(ua) : mobileRE.test(ua)
if (
!result &&
opts.tablet &&
opts.featureDetect &&
navigator &&
navigator.maxTouchPoints > 1 &&
ua.indexOf('Macintosh') !== -1 &&
ua.indexOf('Safari') !== -1
) {
result = true
}
return result
}

4

package.json
{
"name": "is-mobile",
"description": "Check if mobile browser.",
"version": "2.1.0",
"version": "2.2.0",
"repository": {

@@ -13,2 +13,3 @@ "type": "git",

"scripts": {
"release": "np",
"test": "prettier-standard '**/*.js' && standard && tape test.js"

@@ -18,2 +19,3 @@ },

"devDependencies": {
"np": "^5.2.1",
"prettier-standard": "^8.0.1",

@@ -20,0 +22,0 @@ "standard": "^12.0.1",

@@ -19,3 +19,3 @@

### mobile({ [ua], [tablet] })
### mobile({ [ua], [tablet], [featureDetect] })

@@ -28,2 +28,4 @@ Returns true if a mobile browser is being used.

To enable feature detection (i.e. namely for iPad with iOS 13), set `featureDetect: true` and `tablet: true`. This will only work in browser environments.
`opts.ua` can also be an instance of a [node.js http request](http://nodejs.org/api/http.html#http_http_incomingmessage), in which

@@ -30,0 +32,0 @@ case it will reader the user agent header.

@@ -11,2 +11,6 @@ var test = require('tape')

'Mozilla/5.0 (iPad; CPU OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13F69 Safari/601.1'
var ios13ipad =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
var ios13ipadpro =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15'

@@ -39,3 +43,7 @@ test('is mobile', function (t) {

global.navigator = { maxTouchPoints: 5 }
t.ok(isMobile({ ua: ios13ipad, tablet: true, featureDetect: true }))
t.ok(isMobile({ ua: ios13ipadpro, tablet: true, featureDetect: true }))
t.end()
})
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