mirror of
https://github.com/xHyroM/roles-bot.git
synced 2024-11-24 01:01:06 +01:00
ddd862f7af
fork of @discordjs/builders why? because djs must use their SHAPESHIFT and other useless things in packages so, yep... this will be moved into rylen
27 lines
626 B
TypeScript
27 lines
626 B
TypeScript
/**
|
|
* Represents a structure that can be checked against another
|
|
* given structure for equality
|
|
*
|
|
* @typeParam T - The type of object to compare the current object to
|
|
*/
|
|
export interface Equatable<T> {
|
|
/**
|
|
* Whether or not this is equal to another structure
|
|
*/
|
|
equals(other: T): boolean;
|
|
}
|
|
|
|
/**
|
|
* Indicates if an object is equatable or not.
|
|
*
|
|
* @param maybeEquatable - The object to check against
|
|
*/
|
|
export function isEquatable(
|
|
maybeEquatable: unknown,
|
|
): maybeEquatable is Equatable<unknown> {
|
|
return (
|
|
maybeEquatable !== null &&
|
|
typeof maybeEquatable === "object" &&
|
|
"equals" in maybeEquatable
|
|
);
|
|
}
|