Socket
Socket
Sign inDemoInstall

shake-monitor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shake-monitor - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

6

dist/shake-monitor.cjs.js

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

'use strict';function isEmptyObject(a){return 0===Object.keys(a).length}function getDelta(a,b){return Math.abs(a-b)}function isFunc(a){return"function"===typeof a}
function createMotionMonitor(a,b){function e(){f&&(k?window.removeEventListener("devicemotion",a,!1):b?b.addEventListener("click",c):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function c(a){(k="granted"===a)?(b.removeEventListener("click",c),e()):console.warn("The permission to listen to DeviceOrientationEvent was not granted")}let f=isDeviceMotionSupported(),k=!isListenerRequirePermission();return{on:e,off:function(){f&&window.removeEventListener("devicemotion",
a,!1)}}}function isDeviceMotionSupported(){return"DeviceMotionEvent"in window}function isListenerRequirePermission(){return isFunc(DeviceMotionEvent.requestPermission)}let defaultOptions={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};
'use strict';function isEmptyObject(a){return 0===Object.keys(a).length}function getDelta(a,b){return Math.abs(a-b)}function isFunc(a){return"function"===typeof a}function isDeviceMotionSupported(){return"DeviceMotionEvent"in window}function isListenerRequirePermission(){return isFunc(DeviceMotionEvent.requestPermission)}
function createMotionMonitor(a,b){function e(){f&&(k?window.removeEventListener("devicemotion",a,!1):b?b.addEventListener("click",c):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function c(){DeviceMotionEvent.requestPermission().then(a=>{(k="granted"===a)?(b.removeEventListener("click",c),e()):console.warn("The permission to listen to DeviceMotionEvent was not granted")})}let f=isDeviceMotionSupported(),k=!isListenerRequirePermission();return{start:e,stop:function(){f&&
window.removeEventListener("devicemotion",a,!1)}}}let defaultOptions={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};
function createShakeMonitor(a){function b(){if(!g)return g=!0,h=performance.now(),d={},n.on(),this}function e(){if(g)return g=!1,n.off(),h=performance.now(),d={},this}function c(){let a=performance.now();a-h>p&&(l.forEach(a=>a()),h=a)}let {autoStart:f,threshold:k,frequency:p,permissionTriggerNode:q}=Object.assign({},defaultOptions,a),n=createMotionMonitor(function(a){let {x:b,y:m,z:f}=a.accelerationIncludingGravity;if(null===b||null===m||null===f)e();else{if(!isEmptyObject(d)){a=getDelta(d.x,b);var g=
getDelta(d.y,m),h=getDelta(d.z,f);isShake(a,g,h,k)&&c()}d.x=b;d.y=m;d.z=f}},q),l=[],g=!1,h,d;f&&b();return{subscribe:function(a){isFunc(a)&&l.push(a);return this},unsubscribe:function(a){isFunc(a)&&(l=l.filter(b=>b!==a));return this},start:b,stop:e}}function isShake(a,b,e,c){return a>c&&b>c||a>c&&e>c||b>c&&e>c}module.exports=createShakeMonitor
function n(b){return"function"===typeof b}
function q(b,c){function k(){f&&(d?window.removeEventListener("devicemotion",b,!1):c?c.addEventListener("click",l):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function l(b){(d="granted"===b)?(c.removeEventListener("click",l),k()):console.warn("The permission to listen to DeviceOrientationEvent was not granted")}let f="DeviceMotionEvent"in window,d=!n(DeviceMotionEvent.requestPermission);return{on:k,off:function(){f&&window.removeEventListener("devicemotion",b,!1)}}}
let t={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};
function q(b,c){function k(){f&&(d?window.removeEventListener("devicemotion",b,!1):c?c.addEventListener("click",l):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function l(){DeviceMotionEvent.requestPermission().then(b=>{(d="granted"===b)?(c.removeEventListener("click",l),k()):console.warn("The permission to listen to DeviceMotionEvent was not granted")})}let f="DeviceMotionEvent"in window,d=!n(DeviceMotionEvent.requestPermission);return{start:k,stop:function(){f&&
window.removeEventListener("devicemotion",b,!1)}}}let t={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};
export default function(b){function c(){if(!g)return g=!0,h=performance.now(),e={},p.on(),this}function k(){if(g)return g=!1,p.off(),h=performance.now(),e={},this}function l(){let a=performance.now();a-h>r&&(m.forEach(a=>a()),h=a)}let {autoStart:f,threshold:d,frequency:r,permissionTriggerNode:u}=Object.assign({},t,b),p=q(function(a){let {x:b,y:c,z:f}=a.accelerationIncludingGravity;if(null===b||null===c||null===f)k();else{if(0!==Object.keys(e).length){a=Math.abs(e.x-b);var g=Math.abs(e.y-
c),h=Math.abs(e.z-f);(a>d&&g>d||a>d&&h>d||g>d&&h>d)&&l()}e.x=b;e.y=c;e.z=f}},u),m=[],g=!1,h,e;f&&c();return{subscribe:function(a){n(a)&&m.push(a);return this},unsubscribe:function(a){n(a)&&(m=m.filter(b=>b!==a));return this},start:c,stop:k}}

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

'use strict';(function(a,c){"object"===typeof exports&&"undefined"!==typeof module?module.exports=c():"function"===typeof define&&define.amd?define(c):(a="undefined"!==typeof globalThis?globalThis:a||self,a.ShakeMonitor=c())})(this,function(){function a(a){return"function"===typeof a}function c(c,d){function k(){g&&(e?window.removeEventListener("devicemotion",c,!1):d?d.addEventListener("click",l):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function l(a){(e="granted"===
a)?(d.removeEventListener("click",l),k()):console.warn("The permission to listen to DeviceOrientationEvent was not granted")}let g="DeviceMotionEvent"in window,e=!a(DeviceMotionEvent.requestPermission);return{on:k,off:function(){g&&window.removeEventListener("devicemotion",c,!1)}}}let t={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};return function(q){function d(){if(!h)return h=!0,m=performance.now(),f={},p.on(),this}function k(){if(h)return h=!1,p.off(),
m=performance.now(),f={},this}function l(){let b=performance.now();b-m>r&&(n.forEach(b=>b()),m=b)}let {autoStart:g,threshold:e,frequency:r,permissionTriggerNode:u}=Object.assign({},t,q),p=c(function(b){let {x:a,y:c,z:d}=b.accelerationIncludingGravity;if(null===a||null===c||null===d)k();else{if(0!==Object.keys(f).length){b=Math.abs(f.x-a);var g=Math.abs(f.y-c),h=Math.abs(f.z-d);(b>e&&g>e||b>e&&h>e||g>e&&h>e)&&l()}f.x=a;f.y=c;f.z=d}},u),n=[],h=!1,m,f;g&&d();return{subscribe:function(b){a(b)&&n.push(b);
return this},unsubscribe:function(b){a(b)&&(n=n.filter(a=>a!==b));return this},start:d,stop:k}}})
'use strict';(function(a,c){"object"===typeof exports&&"undefined"!==typeof module?module.exports=c():"function"===typeof define&&define.amd?define(c):(a="undefined"!==typeof globalThis?globalThis:a||self,a.ShakeMonitor=c())})(this,function(){function a(a){return"function"===typeof a}function c(c,d){function k(){g&&(e?window.removeEventListener("devicemotion",c,!1):d?d.addEventListener("click",l):console.warn("Cannot get The permission to listen to DeviceOrientationEvent"))}function l(){DeviceMotionEvent.requestPermission().then(a=>
{(e="granted"===a)?(d.removeEventListener("click",l),k()):console.warn("The permission to listen to DeviceMotionEvent was not granted")})}let g="DeviceMotionEvent"in window,e=!a(DeviceMotionEvent.requestPermission);return{start:k,stop:function(){g&&window.removeEventListener("devicemotion",c,!1)}}}let t={permissionTriggerNode:document.documentElement,autoStart:!0,threshold:15,frequency:1E3};return function(q){function d(){if(!h)return h=!0,m=performance.now(),f={},p.on(),this}function k(){if(h)return h=
!1,p.off(),m=performance.now(),f={},this}function l(){let b=performance.now();b-m>r&&(n.forEach(b=>b()),m=b)}let {autoStart:g,threshold:e,frequency:r,permissionTriggerNode:u}=Object.assign({},t,q),p=c(function(b){let {x:a,y:c,z:d}=b.accelerationIncludingGravity;if(null===a||null===c||null===d)k();else{if(0!==Object.keys(f).length){b=Math.abs(f.x-a);var g=Math.abs(f.y-c),h=Math.abs(f.z-d);(b>e&&g>e||b>e&&h>e||g>e&&h>e)&&l()}f.x=a;f.y=c;f.z=d}},u),n=[],h=!1,m,f;g&&d();return{subscribe:function(b){a(b)&&
n.push(b);return this},unsubscribe:function(b){a(b)&&(n=n.filter(a=>a!==b));return this},start:d,stop:k}}})
{
"name": "shake-monitor",
"version": "0.2.1",
"version": "0.2.2",
"description": "shake-monitor",

@@ -5,0 +5,0 @@ "keywords": [

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