UNPKG

@donation-alerts/common

Version:

Common utils and types that are used in other @donation-alerts packages.

27 lines (26 loc) 1.07 kB
import { DataObject } from "./data-object.mjs"; 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 */ export function ReadDocumentation(pkg) { return cls => { Object.defineProperty(cls.prototype, Symbol.for('nodejs.util.inspect.custom'), { value: function (_, options, inspect) { if (this instanceof 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, }); }; }