mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
* chore: use descriptive type parameter names * refactor: requested changes --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
21 lines
608 B
TypeScript
21 lines
608 B
TypeScript
/**
|
|
* Represents an object capable of representing itself as a JSON object
|
|
*
|
|
* @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.
|
|
*/
|
|
export interface JSONEncodable<Value> {
|
|
/**
|
|
* Transforms this object to its JSON format
|
|
*/
|
|
toJSON(): Value;
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|