@whitesev/utils 2.11.3 → 2.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +53 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +53 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +53 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +53 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +53 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +53 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Utils.d.ts +20 -0
- package/package.json +1 -1
- package/src/Utils.ts +72 -0
package/dist/index.iife.js
CHANGED
|
@@ -240,7 +240,7 @@ var Utils = (function () {
|
|
|
240
240
|
const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
|
|
241
241
|
const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
|
|
242
242
|
|
|
243
|
-
const version = "2.11.
|
|
243
|
+
const version = "2.11.4";
|
|
244
244
|
|
|
245
245
|
/* eslint-disable */
|
|
246
246
|
// ==UserScript==
|
|
@@ -8483,6 +8483,58 @@ var Utils = (function () {
|
|
|
8483
8483
|
}
|
|
8484
8484
|
});
|
|
8485
8485
|
}
|
|
8486
|
+
calcPositionDistance(...args) {
|
|
8487
|
+
let position = {
|
|
8488
|
+
x: 0,
|
|
8489
|
+
y: 0,
|
|
8490
|
+
};
|
|
8491
|
+
let otherPosition = {
|
|
8492
|
+
x: 0,
|
|
8493
|
+
y: 0,
|
|
8494
|
+
};
|
|
8495
|
+
if (typeof args[0] === "object" && args[0] != null && typeof args[1] === "object" && args[1] != null) {
|
|
8496
|
+
position = args[0];
|
|
8497
|
+
otherPosition = args[1];
|
|
8498
|
+
}
|
|
8499
|
+
else if (args.length === 4) {
|
|
8500
|
+
position = {
|
|
8501
|
+
x: args[0],
|
|
8502
|
+
y: args[1],
|
|
8503
|
+
};
|
|
8504
|
+
otherPosition = {
|
|
8505
|
+
x: args[2],
|
|
8506
|
+
y: args[3],
|
|
8507
|
+
};
|
|
8508
|
+
}
|
|
8509
|
+
else {
|
|
8510
|
+
throw new Error("Invalid arguments");
|
|
8511
|
+
}
|
|
8512
|
+
if (typeof position.x === "string") {
|
|
8513
|
+
position.x = Number(position.x);
|
|
8514
|
+
}
|
|
8515
|
+
if (isNaN(position.x)) {
|
|
8516
|
+
throw new Error(`Invalid x: ${position.x}`);
|
|
8517
|
+
}
|
|
8518
|
+
if (typeof position.y === "string") {
|
|
8519
|
+
position.y = Number(position.y);
|
|
8520
|
+
}
|
|
8521
|
+
if (isNaN(position.y)) {
|
|
8522
|
+
throw new Error(`Invalid y: ${position.y}`);
|
|
8523
|
+
}
|
|
8524
|
+
if (typeof otherPosition.x === "string") {
|
|
8525
|
+
otherPosition.x = Number(otherPosition.x);
|
|
8526
|
+
}
|
|
8527
|
+
if (isNaN(otherPosition.x)) {
|
|
8528
|
+
throw new Error(`Invalid x: ${otherPosition.x}`);
|
|
8529
|
+
}
|
|
8530
|
+
if (typeof otherPosition.y === "string") {
|
|
8531
|
+
otherPosition.y = Number(otherPosition.y);
|
|
8532
|
+
}
|
|
8533
|
+
if (isNaN(otherPosition.y)) {
|
|
8534
|
+
throw new Error(`Invalid y: ${otherPosition.y}`);
|
|
8535
|
+
}
|
|
8536
|
+
return Math.sqrt(Math.pow(otherPosition.x - position.x, 2) + Math.pow(otherPosition.y - position.y, 2));
|
|
8537
|
+
}
|
|
8486
8538
|
}
|
|
8487
8539
|
const utils = new Utils();
|
|
8488
8540
|
|