export interface DevMessage { type: 'warn' | 'notice'; args: unknown[]; } class DevMessages { _skip = false; displayed: DevMessage[] = []; skipped: DevMessage[] = []; constructor() { this.skip = this.skip.bind(this); this.warn = this.warn.bind(this); this.notice = this.notice.bind(this); } skip(skip?: boolean) { if (skip === undefined) { return this._skip; } return (this._skip = skip); } warn(...args: unknown[]) { if (!this._skip) { this.displayed.push({ type: 'warn', args }); console.warn(...args); } else { this.skipped.push({ type: 'warn', args }); } } notice(...args: unknown[]) { if (!this._skip) { this.displayed.push({ type: 'notice', args }); console.trace('⚠️', ...args); } else { this.skipped.push({ type: 'notice', args }); } } } const devMessages = new DevMessages(); export { devMessages }; export const skipDevMessages = devMessages.skip;