Socket
Socket
Sign inDemoInstall

shake-monitor

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.6 to 0.2.7

8

dist/shake-monitor.cjs.js
'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){let b=isDeviceMotionSupported(),d=!isListenerRequirePermission();return{start:function(){b&&d&&window.removeEventListener("devicemotion",a,!1)},stop:function(){b&&d&&window.removeEventListener("devicemotion",a,!1)},requestPermission:function(a=document.documentElement){return b?d?Promise.resolve(!0):new Promise(b=>{function c(){DeviceMotionEvent.requestPermission().then(e=>{(d="granted"===e)||console.warn("The permission to listen to DeviceMotionEvent was not granted");
a.removeEventListener("click",c);b(d)})}a.addEventListener("click",c)}):Promise.resolve(!1)}}}let defaultOptions={threshold:15,frequency:1E3};
function createShakeMonitor(a){function b(){g&&(g=!1,k.stop(),h=performance.now(),f={});return this}function d(){let a=performance.now();a-h>p&&(e.forEach(a=>a()),h=a)}let {threshold:c,frequency:p}=Object.assign({},defaultOptions,a),k=createMotionMonitor(function(a){let {x:m,y:l,z:e}=a.accelerationIncludingGravity;if(null===m||null===l||null===e)b();else{if(!isEmptyObject(f)){a=getDelta(f.x,m);var g=getDelta(f.y,l),h=getDelta(f.z,e);isShake(a,g,h,c)&&d()}f.x=m;f.y=l;f.z=e}}),e=[],g=!1,n=!1,h,f;return{subscribe:function(a){isFunc(a)&&
e.push(a);return this},unsubscribe:function(a){isFunc(a)&&(e=e.filter(b=>b!==a));return this},start:function(){g||(g=!0,k.start(),h=performance.now(),f={});return this},stop:b,requestPermission:function(a){return n?Promise.resolve(!0):k.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})}}}function isShake(a,b,d,c){return a>c&&b>c||a>c&&d>c||b>c&&d>c}module.exports=createShakeMonitor
function createMotionMonitor(a){let b=isDeviceMotionSupported(),c=!isListenerRequirePermission();return{start:function(){b&&c&&window.removeEventListener("devicemotion",a,!1)},stop:function(){b&&c&&window.removeEventListener("devicemotion",a,!1)},requestPermission:function(a=document.documentElement){return b?c?Promise.resolve(!0):new Promise(b=>{function d(){DeviceMotionEvent.requestPermission().then(e=>{(c="granted"===e)||console.warn("The permission to listen to DeviceMotionEvent was not granted");
a.removeEventListener("click",d);b(c)})}a.addEventListener("click",d)}):Promise.resolve(!1)},confirmPermission:function(){c=!0}}}let defaultOptions={threshold:15,frequency:1E3};
function createShakeMonitor(a){function b(){h&&(h=!1,g.stop(),k=performance.now(),f={});return this}function c(){let a=performance.now();a-k>p&&(e.forEach(a=>a()),k=a)}let {threshold:d,frequency:p}=Object.assign({},defaultOptions,a),g=createMotionMonitor(function(a){let {x:m,y:l,z:e}=a.accelerationIncludingGravity;if(null===m||null===l||null===e)b();else{if(!isEmptyObject(f)){a=getDelta(f.x,m);var g=getDelta(f.y,l),h=getDelta(f.z,e);isShake(a,g,h,d)&&c()}f.x=m;f.y=l;f.z=e}}),e=[],h=!1,n=!1,k,f;return{subscribe:function(a){isFunc(a)&&
e.push(a);return this},unsubscribe:function(a){isFunc(a)&&(e=e.filter(b=>b!==a));return this},start:function(){h||(h=!0,g.start(),k=performance.now(),f={});return this},stop:b,requestPermission:function(a){return n?Promise.resolve(!0):g.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})},confirmPermission:function(){n=!0;g.confirmPermission();return this}}}function isShake(a,b,c,d){return a>d&&b>d||a>d&&c>d||b>d&&c>d}module.exports=createShakeMonitor
//# sourceMappingURL=shake-monitor.cjs.js.map
function m(b){return"function"===typeof b}
function p(b){let d="DeviceMotionEvent"in window,h=!m(DeviceMotionEvent.requestPermission);return{start:function(){d&&h&&window.removeEventListener("devicemotion",b,!1)},stop:function(){d&&h&&window.removeEventListener("devicemotion",b,!1)},requestPermission:function(e=document.documentElement){return d?h?Promise.resolve(!0):new Promise(b=>{function d(){DeviceMotionEvent.requestPermission().then(c=>{(h="granted"===c)||console.warn("The permission to listen to DeviceMotionEvent was not granted");e.removeEventListener("click",
d);b(h)})}e.addEventListener("click",d)}):Promise.resolve(!1)}}}let r={threshold:15,frequency:1E3};
export default function(b){function d(){g&&(g=!1,l.stop(),k=performance.now(),f={});return this}function h(){let a=performance.now();a-k>q&&(c.forEach(a=>a()),k=a)}let {threshold:e,frequency:q}=Object.assign({},r,b),l=p(function(a){let {x:b,y:c,z:g}=a.accelerationIncludingGravity;if(null===b||null===c||null===g)d();else{if(0!==Object.keys(f).length){a=Math.abs(f.x-b);var k=Math.abs(f.y-c),l=Math.abs(f.z-g);(a>e&&k>e||a>e&&l>e||k>e&&l>e)&&h()}f.x=b;f.y=c;f.z=g}}),c=[],g=!1,n=!1,k,f;return{subscribe:function(a){m(a)&&
c.push(a);return this},unsubscribe:function(a){m(a)&&(c=c.filter(b=>b!==a));return this},start:function(){g||(g=!0,l.start(),k=performance.now(),f={});return this},stop:d,requestPermission:function(a){return n?Promise.resolve(!0):l.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})}}}
function p(b){let f="DeviceMotionEvent"in window,g=!m(DeviceMotionEvent.requestPermission);return{start:function(){f&&g&&window.removeEventListener("devicemotion",b,!1)},stop:function(){f&&g&&window.removeEventListener("devicemotion",b,!1)},requestPermission:function(d=document.documentElement){return f?g?Promise.resolve(!0):new Promise(b=>{function c(){DeviceMotionEvent.requestPermission().then(f=>{(g="granted"===f)||console.warn("The permission to listen to DeviceMotionEvent was not granted");d.removeEventListener("click",
c);b(g)})}d.addEventListener("click",c)}):Promise.resolve(!1)},confirmPermission:function(){g=!0}}}let r={threshold:15,frequency:1E3};
export default function(b){function f(){k&&(k=!1,c.stop(),l=performance.now(),e={});return this}function g(){let a=performance.now();a-l>q&&(h.forEach(a=>a()),l=a)}let {threshold:d,frequency:q}=Object.assign({},r,b),c=p(function(a){let {x:b,y:c,z:h}=a.accelerationIncludingGravity;if(null===b||null===c||null===h)f();else{if(0!==Object.keys(e).length){a=Math.abs(e.x-b);var k=Math.abs(e.y-c),l=Math.abs(e.z-h);(a>d&&k>d||a>d&&l>d||k>d&&l>d)&&g()}e.x=b;e.y=c;e.z=h}}),h=[],k=!1,n=!1,l,e;return{subscribe:function(a){m(a)&&
h.push(a);return this},unsubscribe:function(a){m(a)&&(h=h.filter(b=>b!==a));return this},start:function(){k||(k=!0,c.start(),l=performance.now(),e={});return this},stop:f,requestPermission:function(a){return n?Promise.resolve(!0):c.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})},confirmPermission:function(){n=!0;c.confirmPermission();return this}}}
//# sourceMappingURL=shake-monitor.esm.js.map

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

'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){let d="DeviceMotionEvent"in window,h=!a(DeviceMotionEvent.requestPermission);return{start:function(){d&&h&&window.removeEventListener("devicemotion",c,!1)},stop:function(){d&&h&&window.removeEventListener("devicemotion",
c,!1)},requestPermission:function(a=document.documentElement){return d?h?Promise.resolve(!0):new Promise(c=>{function d(){DeviceMotionEvent.requestPermission().then(f=>{(h="granted"===f)||console.warn("The permission to listen to DeviceMotionEvent was not granted");a.removeEventListener("click",d);c(h)})}a.addEventListener("click",d)}):Promise.resolve(!1)}}}let r={threshold:15,frequency:1E3};return function(p){function d(){k&&(k=!1,m.stop(),l=performance.now(),e={});return this}function h(){let b=
performance.now();b-l>q&&(g.forEach(b=>b()),l=b)}let {threshold:f,frequency:q}=Object.assign({},r,p),m=c(function(b){let {x:a,y:c,z:g}=b.accelerationIncludingGravity;if(null===a||null===c||null===g)d();else{if(0!==Object.keys(e).length){b=Math.abs(e.x-a);var k=Math.abs(e.y-c),l=Math.abs(e.z-g);(b>f&&k>f||b>f&&l>f||k>f&&l>f)&&h()}e.x=a;e.y=c;e.z=g}}),g=[],k=!1,n=!1,l,e;return{subscribe:function(b){a(b)&&g.push(b);return this},unsubscribe:function(b){a(b)&&(g=g.filter(a=>a!==b));return this},start:function(){k||
(k=!0,m.start(),l=performance.now(),e={});return this},stop:d,requestPermission:function(a){return n?Promise.resolve(!0):m.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})}}}})
'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){let f="DeviceMotionEvent"in window,g=!a(DeviceMotionEvent.requestPermission);return{start:function(){f&&g&&window.removeEventListener("devicemotion",c,!1)},stop:function(){f&&g&&window.removeEventListener("devicemotion",
c,!1)},requestPermission:function(a=document.documentElement){return f?g?Promise.resolve(!0):new Promise(c=>{function d(){DeviceMotionEvent.requestPermission().then(f=>{(g="granted"===f)||console.warn("The permission to listen to DeviceMotionEvent was not granted");a.removeEventListener("click",d);c(g)})}a.addEventListener("click",d)}):Promise.resolve(!1)},confirmPermission:function(){g=!0}}}let r={threshold:15,frequency:1E3};return function(p){function f(){k&&(k=!1,d.stop(),m=performance.now(),e=
{});return this}function g(){let b=performance.now();b-m>q&&(h.forEach(b=>b()),m=b)}let {threshold:l,frequency:q}=Object.assign({},r,p),d=c(function(b){let {x:a,y:c,z:d}=b.accelerationIncludingGravity;if(null===a||null===c||null===d)f();else{if(0!==Object.keys(e).length){b=Math.abs(e.x-a);var h=Math.abs(e.y-c),k=Math.abs(e.z-d);(b>l&&h>l||b>l&&k>l||h>l&&k>l)&&g()}e.x=a;e.y=c;e.z=d}}),h=[],k=!1,n=!1,m,e;return{subscribe:function(b){a(b)&&h.push(b);return this},unsubscribe:function(b){a(b)&&(h=h.filter(a=>
a!==b));return this},start:function(){k||(k=!0,d.start(),m=performance.now(),e={});return this},stop:f,requestPermission:function(a){return n?Promise.resolve(!0):d.requestPermission(a).then(a=>{n=a;return Promise.resolve(a)})},confirmPermission:function(){n=!0;d.confirmPermission();return this}}}})
//# sourceMappingURL=shake-monitor.umd.js.map
{
"name": "shake-monitor",
"version": "0.2.6",
"version": "0.2.7",
"description": "shake-monitor",

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

Sorry, the diff of this file is not supported yet

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc