UNPKG

gnablib

Version:

A lean, zero dependency library to provide a useful base for your project.

1 lines 734 B
import{color as t}from"../../cli/csi-tables.js";const e=Symbol.for("nodejs.util.inspect.custom"),{cyan:r,magenta:o,reset:n}=t;export class TypeProblem{constructor(t,e,r,o="",n=""){this.noun=t,this._beforeExpect=e,this._expect=r,this._afterExpect=o,this._got=n}toString(){return`${this.noun} ${this._beforeExpect}${this._expect}${this._afterExpect}${this._got}`}inColor(){return`${r}${this.noun}${n} ${this._beforeExpect}${o}${this._expect}${n}${this._afterExpect}${o}${this._got}${n}`}get name(){return"TypeProblem"}get[Symbol.toStringTag](){return"TypeProblem"}[e](){return this.inColor()}static UnexpVal(t,e,r){return new TypeProblem(t,"should be ",r,", got ",typeof e)}static Null(t){return new TypeProblem(t,"cannot be ","null")}}