mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix(utils): remove hasProperty. Unused function
This commit is contained in:
@@ -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<HelperUtils>) {
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
@@ -13,15 +13,3 @@ export function delay(ms: number): Promise<void> {
|
||||
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<T extends {}, Y extends PropertyKey = string>(
|
||||
obj: T,
|
||||
prop: Y,
|
||||
): obj is T & Record<Y, unknown> {
|
||||
// deno-lint-ignore no-prototype-builtins
|
||||
return obj.hasOwnProperty(prop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user