code: function parse(text) {
    const compCount = U.countComponents(text);
    if (!compCount) {
      return; // undefined
    }
  
    const len = text.length,
      components = new Array(compCount);
  
    let multiplier = 1,
      pos = 0,
      nextComp = 0;
  
    //console.log(`parsing unit ${text}:`);
    while (pos < len) {
      let ch = text.charCodeAt(pos);
  
      if (ch === U.slash) {
        multiplier *= -1;
        pos++;
      } else if (ch === U.asterisk) {
        pos++;
      }
  
      let s = pos;
      for (; pos < len; pos++) {
        ch = text.charCodeAt(pos);
  
        if (!U.isLetter(ch)) {
          break;
        }
      }
  
      const name = text.substring(s, pos);
      const unitType = bySid[name];
      if (!unitType) {
        throw new Error(`Unknown unit type "${name}" in "${text}"`);
      }
  
      if (pos < len && text.charCodeAt(pos) === U.caret) {
        pos++;
      }
  
      s = pos;
      if (pos < len && text.charCodeAt(pos) === U.minus) {
        pos++;
      }
  
      while (pos < len && U.isDigit(text.charCodeAt(pos))) {
        pos++;
      }
  
      const degreeText = text.substring(s, pos);
  
      let degree;
      if (!degreeText.length) {
        degree = 1;
      } else {
        degree = Number.parseInt(degreeText);
        if (isNaN(degree)) {
          throw new Error(`Illegal degree "${degreeText}" in "${text}"`);
        }
      }
  
      degree *= multiplier;
  
      let ci = 0;
      for (; ci < nextComp; ci++) {
        const comp = components[ci];
  
        if (comp.unitType === unitType) {
          comp.degree += degree;
          break;
        }
      }
  
      if (ci >= nextComp) {
        components[nextComp++] = new UnitTypeDegree(unitType, degree);
      }
  
      //console.log(` + ${name} ==> ${degree}`);
    }
  
    components.length = nextComp;
    return parseComponents(components);
  }
docs: UnitType Parsing