All files / src/lib util.ts

100% Statements 11/11
100% Branches 3/3
100% Functions 5/5
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 206x   6x   6x 6x 6x 6x       1x 1x       1x      
import {LOG_COLORS, LOG_TYPES} from "./enums";
 
export class Util {
  static wrapGroup(name: string, description: string, fn: Function, color: LOG_COLORS = LOG_COLORS.GREEN) {
    const logConfig = (name: string, color: LOG_COLORS) => ['%c' + name, `background: ${color}; color: white; padding: 2px 0.5em; ` + `border-radius: 0.5em;`];
    window.console.groupCollapsed(...logConfig(name, color), description);
    fn();
    window.console.groupEnd();
  }
 
  static log(content: any, type: LOG_TYPES = LOG_TYPES.INFO, color: LOG_COLORS = LOG_COLORS.BLUE) {
    const logConfig = color => ['%cPuzzleJs', `background: ${color}; color: white; padding: 2px 0.5em; ` + `border-radius: 0.5em;`];
    window.console[type](...logConfig(color), content);
  }
 
  static table(content: object) {
    window.console.table(content);
  }
}