diff --git a/bot.ts b/bot.ts index 6e0c0a6dc..649972bc4 100644 --- a/bot.ts +++ b/bot.ts @@ -32,7 +32,7 @@ import { } from "./util/constants.ts"; import { createGatewayManager, GatewayManager } from "./gateway/manager/gatewayManager.ts"; import { validateLength } from "./util/validateLength.ts"; -import { delay, formatImageURL, hasProperty } from "./util/utils.ts"; +import { delay, formatImageURL } from "./util/utils.ts"; import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts"; import { calculateShardId } from "./util/calculateShardId.ts"; import * as handlers from "./handlers/mod.ts"; @@ -276,7 +276,6 @@ export function createUtils(options: Partial) { iconHashToBigInt, iconBigintToHash, validateLength, - hasProperty, urlToBase64, formatImageURL, calculateBits, @@ -292,7 +291,6 @@ export interface HelperUtils { iconHashToBigInt: typeof iconHashToBigInt; iconBigintToHash: typeof iconBigintToHash; validateLength: typeof validateLength; - hasProperty: typeof hasProperty; urlToBase64: typeof urlToBase64; formatImageURL: typeof formatImageURL; calculateBits: typeof calculateBits; diff --git a/tests/util/utils.ts b/tests/util/utils.ts deleted file mode 100644 index 8a386bc79..000000000 --- a/tests/util/utils.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { delay, hasProperty } from "../../util/utils.ts"; -import { assertEquals } from "../deps.ts"; - -// hasProperty - -const obj = { prop: "lts372005" }; -Deno.test({ - name: "[utils] hasProperty does HAVE property", - fn() { - assertEquals(hasProperty(obj, "prop"), true); - }, -}); -Deno.test({ - name: "[utils] hasProperty does NOT HAVE property", - fn() { - assertEquals(hasProperty(obj, "lts372005"), false); - }, -}); - -// delay diff --git a/util/utils.ts b/util/utils.ts index 59f5e328d..539ab65c6 100644 --- a/util/utils.ts +++ b/util/utils.ts @@ -13,15 +13,3 @@ export function delay(ms: number): Promise { export function formatImageURL(url: string, size: ImageSize = 128, format?: ImageFormat) { return `${url}.${format || (url.includes("/a_") ? "gif" : "jpg")}?size=${size}`; } - -// Typescript is not so good as we developers so we need this little utility function to help it out -// Taken from https://fettblog.eu/typescript-hasownproperty/ -/** TS save way to check if a property exists in an object */ -// deno-lint-ignore ban-types -export function hasProperty( - obj: T, - prop: Y, -): obj is T & Record { - // deno-lint-ignore no-prototype-builtins - return obj.hasOwnProperty(prop); -}