summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2025-11-25 23:37:20 -0600
committerMathMan05 <mathmanrm@gmail.com>2025-11-25 23:37:20 -0600
commit319b420fc099bf5cb0d2a0a2756e248fc9fed763 (patch)
tree8371d2a48ca82bfd9d4e5d2e878a88ea2b2bde9b
parentrid of contains all (diff)
downloadserver-ts-319b420fc099bf5cb0d2a0a2756e248fc9fed763.tar.xz
remove unused forEach
-rw-r--r--src/util/util/extensions/Object.test.ts13
-rw-r--r--src/util/util/extensions/Object.ts18
2 files changed, 0 insertions, 31 deletions
diff --git a/src/util/util/extensions/Object.test.ts b/src/util/util/extensions/Object.test.ts

index 570b8024..1bcd487e 100644 --- a/src/util/util/extensions/Object.test.ts +++ b/src/util/util/extensions/Object.test.ts
@@ -5,19 +5,6 @@ import { describe, it } from "node:test"; import assert from "node:assert/strict"; describe("Object extensions", () => { - it("forEach", async () => { - const obj: { [index:string]: number } = { a: 1, b: 2, c: 3 }; - const keys: string[] = []; - const values: number[] = []; - obj.forEach<number>((value, key, _) => { - keys.push(key); - values.push(value); - }); - console.log(keys, values); - assert.deepEqual(keys, ["a", "b", "c"]); - assert.deepEqual(values, [1, 2, 3]); - }); - it("map", async () => { const obj = { a: 1, b: 2, c: 3 }; const result = obj.map((value, key) => `${key}:${value}`); diff --git a/src/util/util/extensions/Object.ts b/src/util/util/extensions/Object.ts
index bda4ccf2..894fbba3 100644 --- a/src/util/util/extensions/Object.ts +++ b/src/util/util/extensions/Object.ts
@@ -1,16 +1,9 @@ declare global { interface Object { - forEach<T>(callback: (value: T, key: string, object: { [index: string]: T }) => void): void; map<SV, TV>(callback: (value: SV, key: string, object: { [index: string]: SV }) => TV): { [index: string]: TV }; } } -export function objectForEach<T>(obj: { [index: string]: T }, callback: (value: T, key: string, object: { [index: string]: T }) => void): void { - Object.keys(obj).forEach((key) => { - callback(obj[key], key, obj); - }); -} - export function objectMap<SV, TV>(srcObj: { [index: string]: SV }, callback: (value: SV, key: string, object: { [index: string]: SV }) => TV): { [index: string]: TV } { if (typeof callback !== "function") throw new TypeError(`${callback} is not a function`); const obj: { [index: string]: TV } = {}; @@ -20,17 +13,6 @@ export function objectMap<SV, TV>(srcObj: { [index: string]: SV }, callback: (va return obj; } -if (!Object.prototype.forEach) - Object.defineProperty(Object.prototype, "forEach", { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - value: function (cb) { - return objectForEach(this, cb); - }, - enumerable: false, - writable: true, - }); - if (!Object.prototype.map) Object.defineProperty(Object.prototype, "map", { // eslint-disable-next-line @typescript-eslint/ban-ts-comment