dexscreener-sdk
Version:
A TypeScript wrapper for the DEX Screener API, providing easy access to token profiles, boosts, orders, pairs, and more.
25 lines (24 loc) • 709 B
JavaScript
/**
* BaseModel serves as the base class for all models.
* It initializes the model with given data and provides a method to convert
* the model instance to a plain JavaScript object.
*/
export class BaseModel {
/**
* Constructs a new instance of BaseModel.
* @param data Partial data to initialize the model.
*/
constructor(data) {
if (data) {
Object.assign(this, data);
}
}
/**
* Converts the model instance into a plain object.
* @returns A plain object representation of the model.
*/
toJSON() {
// Using an explicit type assertion to satisfy TypeScript.
return { ...this };
}
}