@donation-alerts/common
Version:
Common utils and types that are used in other @donation-alerts packages.
30 lines (29 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadDocumentation = ReadDocumentation;
const data_object_1 = require("./data-object");
const ANSI_CYAN = '\u001b[36m';
const ANSI_GRAY = '\u001b[90m';
const ANSI_RESET = '\u001b[0m';
const BASE_URL = 'https://stimulcross.github.io/donation-alerts';
const PACKAGE_MAP = {
api: 'api',
'api-call': 'api_call',
auth: 'auth',
common: 'common',
events: 'events',
};
/** @internal */
function ReadDocumentation(pkg) {
return cls => {
Object.defineProperty(cls.prototype, Symbol.for('nodejs.util.inspect.custom'), {
value: function (_, options, inspect) {
if (this instanceof data_object_1.DataObject) {
return `${ANSI_CYAN}[${cls.name}]${ANSI_RESET} ${inspect(this.toJSON(), options)} ${ANSI_GRAY}- see docs to explore all members: ${BASE_URL}/classes/${PACKAGE_MAP[pkg]}.${cls.name}.html${ANSI_RESET}`;
}
return `${ANSI_CYAN}[${cls.name}]${ANSI_RESET} - see docs to explore all members: ${BASE_URL}/classes/${PACKAGE_MAP[pkg]}.${cls.name}.html`;
},
enumerable: false,
});
};
}