mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
15 lines
425 B
TypeScript
15 lines
425 B
TypeScript
export interface JSONEncodable<T> {
|
|
/**
|
|
* Transforms this object to its JSON format
|
|
*/
|
|
toJSON: () => T;
|
|
}
|
|
|
|
/**
|
|
* Indicates if an object is encodable or not.
|
|
* @param maybeEncodable The object to check against
|
|
*/
|
|
export function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown> {
|
|
return maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toJSON' in maybeEncodable;
|
|
}
|