UNPKG

tgsnake

Version:

Telegram MTProto framework for nodejs.

59 lines (58 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TLObject = void 0; class TLObject { _client; className; constructor(client) { this._client = client; this.className = this.constructor.name; } get client() { return this._client; } get api() { return this._client.api; } get core() { return this._client._client; } [Symbol.for('nodejs.util.inspect.custom')]() { const toPrint = { _: this.className, }; let ignore = ['className']; for (const key in this) { if (this.hasOwnProperty(key)) { const value = this[key]; if (ignore.includes(key)) continue; if (!key.startsWith('_') && value !== undefined && value !== null) { toPrint[key] = value; } } } return toPrint; } toJSON() { const toPrint = { _: this.className, }; let ignore = ['className']; for (const key in this) { if (this.hasOwnProperty(key)) { const value = this[key]; if (ignore.includes(key)) continue; if (!key.startsWith('_') && value !== undefined && value !== null) { toPrint[key] = typeof value === 'bigint' ? String(value) : value; } } } return toPrint; } toString() { return `[constructor of ${this.className}] ${JSON.stringify(this, null, 2)}`; } } exports.TLObject = TLObject;