Files
discord.js/packages/util/src/Equatable.ts
Almeida 975d5f18ae chore: use descriptive type parameter names (#9937)
* chore: use descriptive type parameter names

* refactor: requested changes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 17:21:51 +00:00

22 lines
623 B
TypeScript

/**
* Represents a structure that can be checked against another
* given structure for equality
*
* @typeParam Value - The type of object to compare the current object to
*/
export interface Equatable<Value> {
/**
* Whether or not this is equal to another structure
*/
equals(other: Value): 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;
}