New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@hscmap/magic-trackpad-detector

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hscmap/magic-trackpad-detector - npm Package Compare versions

Comparing version
0.0.5
to
0.0.6
package-lock.json

Sorry, the diff of this file is too big to display

+2
-1
{
"extends": "../src/tsconfig",
"compilerOptions": {
"noUnusedLocals": true
"noUnusedLocals": true,
"declaration": false
}
}
{
"name": "@hscmap/magic-trackpad-detector",
"version": "0.0.5",
"version": "0.0.6",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts",

export class MagicTrackpadDetector {
tolerance = 5 // ms
interval = 1000 / 60 // events per second
minN1 = 5

@@ -21,8 +19,7 @@ minN2 = 15

const n = h.at(-i + 1)
// const dt = n[0] - o[0]
// if (dt < this.interval - this.tolerance)
// return false
if (n[1] * o[1] < 0 || n[1] / o[1] > 1)
return false
}
if (h.at(-1)[1] == h.at(-this.minN1 + 1)[1])
return false
}

@@ -40,5 +37,2 @@ else { // |deltaY| == 1

const n = h.at(-i + 1)
// const dt = n[0] - o[0]
// if (dt < this.interval - this.tolerance)
// return false
if (n[1] * o[1] < 0 || n[1] / o[1] > 1)

@@ -45,0 +39,0 @@ return false

Sorry, the diff of this file is not supported yet

export declare class MagicTrackpadDetector {
tolerance: number;
interval: number;
minN1: number;
minN2: number;
private history;
inertial(e: WheelEvent): boolean;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MagicTrackpadDetector = (function () {
function MagicTrackpadDetector() {
this.tolerance = 5; // ms
this.interval = 1000 / 60; // events per second
this.minN1 = 5;
this.minN2 = 15;
this.history = new RingBuffer(Math.max(this.minN1, this.minN2));
}
MagicTrackpadDetector.prototype.inertial = function (e) {
var h = this.history;
var t0 = performance.now();
var d0 = e.deltaY;
h.push([t0, d0]);
if (h.length < this.minN1)
return false;
if (Math.abs(e.deltaY) > 1) {
for (var i = this.minN1 - 1; i > 1; --i) {
var o = h.at(-i);
var n = h.at(-i + 1);
// const dt = n[0] - o[0]
// if (dt < this.interval - this.tolerance)
// return false
if (n[1] * o[1] < 0 || n[1] / o[1] > 1)
return false;
}
}
else {
if (h.length < this.minN2)
return false;
var _a = h.at(-this.minN2), to = _a[0], vo = _a[1];
to;
if (Math.abs(vo) <= 1) {
return false;
}
for (var i = this.minN2 - 1; i > 1; --i) {
var o = h.at(-i);
var n = h.at(-i + 1);
// const dt = n[0] - o[0]
// if (dt < this.interval - this.tolerance)
// return false
if (n[1] * o[1] < 0 || n[1] / o[1] > 1)
return false;
}
}
return true;
};
return MagicTrackpadDetector;
}());
exports.MagicTrackpadDetector = MagicTrackpadDetector;
var RingBuffer = (function () {
function RingBuffer(n) {
this.n = n;
this.clear();
}
RingBuffer.prototype.at = function (i) {
var j = (this.o + i + this.length) % this.xs.length;
return this.xs[j];
};
RingBuffer.prototype.push = function (x) {
if (this.xs.length < this.n)
this.xs.push(x);
else
this.xs[this.o] = x;
this.o = (this.o + 1) % this.n;
};
RingBuffer.prototype.clear = function () {
this.o = 0;
this.xs = [];
};
Object.defineProperty(RingBuffer.prototype, "length", {
get: function () {
return this.xs.length;
},
enumerable: true,
configurable: true
});
return RingBuffer;
}());

Sorry, the diff of this file is not supported yet