New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sensors-checker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sensors-checker

Mostly all recent browsers expose an api for deviceorientation and devicemotion events. This module will let you check if there is really an accelerometer+gyroscope to rely on.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

sensorsChecker.js

npm version

Mostly all recent browsers expose an api for deviceorientation and devicemotion events.

  • That doesn't mean the device you're on has sensors (accelerometer+gyroscope) to feed them.
  • So, to check if the device has sensors, you can't rely on simple feature detection like "ondeviceorientation" in window or "ondevicemotion" in window
  • This module will let you check if there is really an accelerometer+gyroscope to rely on.
//check the sensors for the deviceorientation api
sensorsChecker.checkDeviceorientation(function(){
		console.log('sensors detected');
	},function(){
		console.error('no sensor detected');
	}
);
//check the sensors for the devicemotion api (this time with some options)
sensorsChecker.checkDevicemotion(function(){
		console.log('sensors detected');
	},function(){
		console.error('no sensor detected');
	},{
		userAgentCheck: /(iPad|iPhone|Nexus|Mobile|Tablet)/i,//@optional (to bypass the sniffing)
		delay: 600//@optional default delay : 500ms
	}
);

Used in :

Now available on npm: npm install sensors-checker --save

Keywords

FAQs

Package last updated on 13 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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