lib/QRCodeGenerator.js
function _getTypeNumber(content, ecl) {
    var length = _getUTF8Length(content);

    var type = 1;
    var limit = 0;
    for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
      var table = QRCodeLimitLength[i];
      if (!table) {
        throw new Error("Content too long: expected " + limit + " but got " + length);
      }

      switch (ecl) {
        case "L":
          limit = table[0];
          break;

        case "M":
          limit = table[1];
          break;

        case "Q":
          limit = table[2];
          break;

        case "H":
          limit = table[3];
          break;

        default:
          throw new Error("Unknwon error correction level: " + ecl);
      }

      if (length <= limit) {
        break;
      }

      type++;
    }

    if (type > QRCodeLimitLength.length) {
      throw new Error("Content too long");
    }

    return type;
  }
function _getTypeNumber(content, ecl) {
    var length = _getUTF8Length(content);

    var type = 1;
    var limit = 0;
    for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
      var table = QRCodeLimitLength[i];
      if (!table) {
        throw new Error("Content too long: expected " + limit + " but got " + length);
      }

      switch (ecl) {
        case "L":
          limit = table[0];
          break;

        case "M":
          limit = table[1];
          break;

        case "Q":
          limit = table[2];
          break;

        case "H":
          limit = table[3];
          break;

        default:
          throw new Error("Unknwon error correction level: " + ecl);
      }

      if (length <= limit) {
        break;
      }

      type++;
    }

    if (type > QRCodeLimitLength.length) {
      throw new Error("Content too long");
    }

    return type;
  }
function _getTypeNumber ( content , ecl ) { var length = _getUTF8Length ( content ) ; var type = 1 ; var limit = 0 ; for ( var i = 0 , len = QRCodeLimitLength . length ; i <= len ; i ++ ) { var table = QRCodeLimitLength [ i ] ; if ( ! table ) { throw new Error ( "Content too long: expected " + limit + " but got " + length ) ; } switch ( ecl ) { case "L" : limit = table [ 0 ] ; break ; case "M" : limit = table [ 1 ] ; break ; case "Q" : limit = table [ 2 ] ; break ; case "H" : limit = table [ 3 ] ; break ; default : throw new Error ( "Unknwon error correction level: " + ecl ) ; } if ( length <= limit ) { break ; } type ++ ; } if ( type > QRCodeLimitLength . length ) { throw new Error ( "Content too long" ) ; } return type ; }
Get type number
Get type number