diff --git a/src/util/util/extensions/Array.test.ts b/src/util/util/extensions/Array.test.ts
index 454197c1..faabfdea 100644
--- a/src/util/util/extensions/Array.test.ts
+++ b/src/util/util/extensions/Array.test.ts
@@ -74,14 +74,4 @@ describe("Array extensions", () => {
// @ts-expect-error
assert.deepEqual([].intersect(arr2), []);
});
-
- it("except", () => {
- const arr1 = [1, 2, 3, 4];
- const arr2 = [3, 4, 5, 6];
- assert.deepEqual(arr1.except(arr2), [1, 2]);
- assert.deepEqual(arr1.except([]), [1, 2, 3, 4]);
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-expect-error
- assert.deepEqual([].except(arr2), []);
- });
});
diff --git a/src/util/util/extensions/Array.ts b/src/util/util/extensions/Array.ts
index d061edf9..11d93920 100644
--- a/src/util/util/extensions/Array.ts
+++ b/src/util/util/extensions/Array.ts
@@ -26,7 +26,6 @@ declare global {
distinct(): T[];
distinctBy<K>(key: (elem: T) => K): T[];
intersect(other: T[]): T[];
- except(other: T[]): T[];
}
}
@@ -87,10 +86,6 @@ export function arrayIntersect<T>(this: T[], other: T[]): T[] {
return this.filter((value) => other.includes(value));
}
-export function arrayExcept<T>(this: T[], other: T[]): T[] {
- return this.filter((value) => !other.includes(value));
-}
-
// register extensions
if (!Array.prototype.containsAll)
Array.prototype.containsAll = function <T>(this: T[], target: T[]) {
@@ -126,7 +121,3 @@ if (!Array.prototype.intersect)
Array.prototype.intersect = function <T>(this: T[], other: T[]) {
return arrayIntersect.call(this, other);
};
-if (!Array.prototype.except)
- Array.prototype.except = function <T>(this: T[], other: T[]) {
- return arrayExcept.call(this, other);
- };
diff --git a/src/util/util/lambert-server/check.ts b/src/util/util/lambert-server/check.ts
index 4dabc5ce..c60a70f7 100644
--- a/src/util/util/lambert-server/check.ts
+++ b/src/util/util/lambert-server/check.ts
@@ -2,8 +2,7 @@ import { NextFunction, Request, Response } from "express";
import { HTTPError } from ".";
const OPTIONAL_PREFIX = "$";
-const EMAIL_REGEX =
- /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
export function check(schema: any) {
return (req: Request, res: Response, next: NextFunction) => {
@@ -31,11 +30,7 @@ export class Email {
}
}
-export function instanceOf(
- type: any,
- value: any,
- { path = "", optional = false }: { path?: string; optional?: boolean } = {}
-): Boolean {
+export function instanceOf(type: any, value: any, { path = "", optional = false }: { path?: string; optional?: boolean } = {}): boolean {
if (!type) return true; // no type was specified
if (value == null) {
@@ -55,7 +50,9 @@ export function instanceOf(
try {
value = BigInt(value);
if (typeof value === "bigint") return true;
- } catch (error) {}
+ } catch (error) {
+ //Ignore BigInt error
+ }
throw `${path} must be a bigint`;
case Boolean:
if (value == "true") value = true;
@@ -98,9 +95,8 @@ export function instanceOf(
}
if (typeof value !== "object") throw `${path} must be a object`;
- const diff = Object.keys(value).except(
- Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x))
- );
+ const filterset = new Set(Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x)));
+ const diff = Object.keys(value).filter((_) => filterset.has(_));
if (diff.length) throw `Unknown key ${diff}`;
|