From efc15fdca4a9a2860a104e4959e3a934b8d88e69 Mon Sep 17 00:00:00 2001 From: itohatweb Date: Fri, 21 May 2021 15:59:48 +0000 Subject: [PATCH] change: prettier code --- src/cache.ts | 131 +++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 104 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index 76f351156..02f30ca09 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -23,19 +23,12 @@ export const cache = { presences: new Collection(), fetchAllMembersProcessingRequests: new Collection< string, - ( - value: - | Collection - | PromiseLike>, - ) => void + (value: Collection | PromiseLike>) => void >(), executedSlashCommands: new Set(), get emojis() { return new Collection( - this.guilds.reduce( - (a, b) => [...a, ...b.emojis.map((e) => [e.id, e])], - [] as any[], - ), + this.guilds.reduce((a, b) => [...a, ...b.emojis.map((e) => [e.id, e])], [] as any[]) ); }, }; @@ -70,142 +63,72 @@ export let cacheHandlers = { filter, }; -export type TableName = - | "guilds" - | "unavailableGuilds" - | "channels" - | "messages" - | "members" - | "presences"; +export type TableName = "guilds" | "unavailableGuilds" | "channels" | "messages" | "members" | "presences"; -function set( - table: "guilds", - key: bigint, - value: DiscordenoGuild, -): Promise>; -function set( - table: "channels", - key: bigint, - value: DiscordenoChannel, -): Promise>; -function set( - table: "messages", - key: bigint, - value: DiscordenoMessage, -): Promise>; -function set( - table: "members", - key: bigint, - value: DiscordenoMember, -): Promise>; -function set( - table: "presences", - key: bigint, - value: PresenceUpdate, -): Promise>; -function set( - table: "unavailableGuilds", - key: bigint, - value: number, -): Promise>; +function set(table: "guilds", key: bigint, value: DiscordenoGuild): Promise>; +function set(table: "channels", key: bigint, value: DiscordenoChannel): Promise>; +function set(table: "messages", key: bigint, value: DiscordenoMessage): Promise>; +function set(table: "members", key: bigint, value: DiscordenoMember): Promise>; +function set(table: "presences", key: bigint, value: PresenceUpdate): Promise>; +function set(table: "unavailableGuilds", key: bigint, value: number): Promise>; async function set(table: TableName, key: bigint, value: any) { return cache[table].set(key, value); } -function get( - table: "guilds", - key: bigint, -): Promise; -function get( - table: "channels", - key: bigint, -): Promise; -function get( - table: "messages", - key: bigint, -): Promise; -function get( - table: "members", - key: bigint, -): Promise; -function get( - table: "presences", - key: bigint, -): Promise; -function get( - table: "unavailableGuilds", - key: bigint, -): Promise; +function get(table: "guilds", key: bigint): Promise; +function get(table: "channels", key: bigint): Promise; +function get(table: "messages", key: bigint): Promise; +function get(table: "members", key: bigint): Promise; +function get(table: "presences", key: bigint): Promise; +function get(table: "unavailableGuilds", key: bigint): Promise; async function get(table: TableName, key: bigint) { return cache[table].get(key); } function forEach( table: "guilds", - callback: ( - value: DiscordenoGuild, - key: bigint, - map: Map, - ) => unknown, + callback: (value: DiscordenoGuild, key: bigint, map: Map) => unknown ): void; function forEach( table: "unavailableGuilds", - callback: (value: number, key: bigint, map: Map) => unknown, + callback: (value: number, key: bigint, map: Map) => unknown ): void; function forEach( table: "channels", - callback: ( - value: DiscordenoChannel, - key: bigint, - map: Map, - ) => unknown, + callback: (value: DiscordenoChannel, key: bigint, map: Map) => unknown ): void; function forEach( table: "messages", - callback: ( - value: DiscordenoMessage, - key: bigint, - map: Map, - ) => unknown, + callback: (value: DiscordenoMessage, key: bigint, map: Map) => unknown ): void; function forEach( table: "members", - callback: ( - value: DiscordenoMember, - key: bigint, - map: Map, - ) => unknown, + callback: (value: DiscordenoMember, key: bigint, map: Map) => unknown ): void; -function forEach( - table: TableName, - callback: (value: any, key: bigint, map: Map) => unknown, -) { +function forEach(table: TableName, callback: (value: any, key: bigint, map: Map) => unknown) { return cache[table].forEach(callback); } function filter( table: "guilds", - callback: (value: DiscordenoGuild, key: bigint) => boolean, + callback: (value: DiscordenoGuild, key: bigint) => boolean ): Promise>; function filter( table: "unavailableGuilds", - callback: (value: number, key: bigint) => boolean, + callback: (value: number, key: bigint) => boolean ): Promise>; function filter( table: "channels", - callback: (value: DiscordenoChannel, key: bigint) => boolean, + callback: (value: DiscordenoChannel, key: bigint) => boolean ): Promise>; function filter( table: "messages", - callback: (value: DiscordenoMessage, key: bigint) => boolean, + callback: (value: DiscordenoMessage, key: bigint) => boolean ): Promise>; function filter( table: "members", - callback: (value: DiscordenoMember, key: bigint) => boolean, + callback: (value: DiscordenoMember, key: bigint) => boolean ): Promise>; -async function filter( - table: TableName, - callback: (value: any, key: bigint) => boolean, -) { +async function filter(table: TableName, callback: (value: any, key: bigint) => boolean) { return cache[table].filter(callback); }