diff --git a/src/util/util/extensions/Object.test.ts b/src/util/util/extensions/Object.test.ts index 570b80249..1bcd487e8 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((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 bda4ccf21..894fbba31 100644 --- a/src/util/util/extensions/Object.ts +++ b/src/util/util/extensions/Object.ts @@ -1,16 +1,9 @@ declare global { interface Object { - forEach(callback: (value: T, key: string, object: { [index: string]: T }) => void): void; map(callback: (value: SV, key: string, object: { [index: string]: SV }) => TV): { [index: string]: TV }; } } -export function objectForEach(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(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(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