All files / src/utils humanReadable.ts

72.73% Statements 8/11
50% Branches 3/6
100% Functions 1/1
72.73% Lines 8/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  15x 15x 15x               9x     9x 9x       9x          
import isStr from "../preds/isStr";
 
const dict = {
  Z_OR_M: 'zeroOrMore',
  O_OR_M: 'oneOrMore',
  Z_OR_O: 'zeroOrOne',
  COLL_OF: 'collOf',
  MAP_OF: 'mapOf',
};
 
export default function humanReadable( expr ) {
  ifI ( isStr( expr ) ) {
    return expr;
  }
  ifE ( expr.type ) {
    if (I dict[ expr.type ] ) {
      return dict[ expr.type ];
    } else {
      return expr.type.toLowerCase();
    }
  } else {
    return expr.toString();
  }
}