Files
discord.js/packages/builders/src/util/jsonEncodable.ts
2022-02-07 11:52:10 +01:00

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;
}