aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
committerbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
commitcda69e48361fce8d71a4dc66edd9dd976a27f52d (patch)
tree82b9a1a5967ae88a9534f89f7eaed3aeb289652f /src/Utils.ts
parentc01828308714874589d1f60c33ca59df4c656c0c (diff)
parenta958577d4c27b276aa37484e3f895e196138b17c (diff)
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 23ae38bdb..0590c6930 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-namespace */
import * as uuid from 'uuid';
export function clamp(n: number, lower: number, upper: number) {
@@ -23,6 +24,7 @@ export namespace Utils {
export const loggingEnabled = false;
export const logFilter: number | undefined = undefined;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function log(prefixIn: string, messageName: string, messageIn: any, receiving: boolean) {
let prefix = prefixIn;
let message = messageIn;
@@ -38,8 +40,9 @@ export namespace Utils {
console.log(`${prefix}: ${idString}, ${receiving ? 'receiving' : 'sending'} ${messageName} with data ${JSON.stringify(message)} `);
}
- export function loggingCallback(prefix: string, func: (args: any) => any, messageName: string) {
- return (args: any) => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ export function loggingCallback(prefix: string, func: (args: any) => void, messageName: string) {
+ return (args: unknown) => {
log(prefix, messageName, args, true);
func(args);
};
@@ -47,7 +50,9 @@ export namespace Utils {
export function TraceConsoleLog() {
['log', 'warn'].forEach(method => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const old = (console as any)[method];
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
(console as any)[method] = function (...args: any[]) {
let stack = new Error('').stack?.split(/\n/);
// Chrome includes a single "Error" line, FF doesn't.
@@ -158,7 +163,7 @@ export function timenow() {
const now = new Date();
let ampm = 'am';
let h = now.getHours();
- let m: any = now.getMinutes();
+ let m: string | number = now.getMinutes();
if (h >= 12) {
if (h > 12) h -= 12;
ampm = 'pm';
@@ -201,7 +206,7 @@ export function intersectRect(r1: { left: number; top: number; width: number; he
export function stringHash(s?: string) {
// eslint-disable-next-line no-bitwise
- return !s ? undefined : Math.abs(s.split('').reduce((a: any, b: any) => (n => n & n)((a << 5) - a + b.charCodeAt(0)), 0));
+ return !s ? undefined : Math.abs(s.split('').reduce((a, b) => (n => n & n)((a << 5) - a + b.charCodeAt(0)), 0));
}
export function percent2frac(percent: string) {
@@ -224,8 +229,6 @@ export function emptyFunction() {
return undefined;
}
-export const emptyPath: any[] = [];
-
export function unimplementedFunction() {
throw new Error('This function is not implemented, but should be.');
}
@@ -246,6 +249,7 @@ export function DeepCopy<K, V>(source: Map<K, V>, predicate?: Predicate<K, V>) {
export namespace JSONUtils {
export function tryParse(source: string) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
let results: any;
try {
results = JSON.parse(source);