Check if token is part of an escaped string (e.g. `~"ms:something"`).
@param {Number} i Token's index number
@returns {Number} Length of the string (including `~` and quotes)
165948
function checkEscapedString(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  if (tokens[i].type === TokenType.Tilde && (l = checkString(i + 1)))
    return i + l - start;
  else return 0;
}
1107743
function (str, token) {
            var total = 0, i;
            while ((i = str.indexOf(token, i) + 1)) {
                total++;
            }
            return total;
        }
133720
private function MatchQuoted($quote_char, $i){

		$matched = '';
		while( $i < $this->input_len ){
			$c = $this->input[$i];

			//escaped character
			if( $c === '\\' ){
				$matched .= $c . $this->input[$i+1];
				$i += 2;
				continue;
			}

			if( $c === $quote_char ){
				$this->pos = $i+1;
				$this->skipWhitespace(0);
				return $matched;
			}

			if( $c === "\r" || $c === "\n" ){
				return false;
			}

			$i++;
			$matched .= $c;
		}

		return false;
	}
356813
function checkS(i) {
  return i < tokensLength && tokens[i].ws ? tokens[i].ws_last - i + 1 : 0;
}
1037987
function checkSelector1(i) {
  if (i >= tokensLength) return 0;

  const start = i;
  let l;

  if (l = checkCompoundSelector(i)) i += l;
  else return 0;

  while (i < tokensLength) {
    let space = checkSC(i);
    const comma = checkCombinator(i + space);
    if (!space && !comma) break;

    if (comma) {
      i += space + comma;
      space = checkSC(i);
    }

    if (l = checkCompoundSelector(i + space)) i += space + l;
    else break;
  }

  tokens[start].selectorEnd = i;
  return i - start;
}
1178233
function checkPseudoClass2(i) {
  const start = i;
  let l;

  // Skip `:`.
  i++;

  if (i >= tokensLength) return 0;

  if (l = checkIdentOrInterpolation(i)) i += l;
  else return 0;

  if (i >= tokensLength ||
      tokens[i].type !== TokenType.LeftParenthesis) return 0;

  const right = tokens[i].right;

  // Skip `(`.
  i++;

  if (l = checkSC(i)) i += l;

  if (l = checkIdentOrInterpolation(i)) i += l;
  else return 0;

  if (l = checkSC(i)) i += l;

  if (i !== right) return 0;

  // Skip `)`.
  i++;

  return i - start;
}
166522
function checkCondition(i) {
  const start = i;
  let l;
  let _i;
  let s;

  if (i >= tokensLength) return 0;

  if (l = checkAtkeyword(i)) i += l;
  else return 0;

  if (['if', 'else'].indexOf(tokens[start + 1].value) < 0) return 0;

  while (i < tokensLength) {
    if (l = checkBlock(i)) break;

    s = checkSC(i);
    _i = i + s;

    if (l = _checkCondition(_i)) i += l + s;
    else break;
  }

  return i - start;
}
422877
function checkLength(str) {
        var ctm = ctx.measureText(str);
        return ctm.width <= tm.width;
      }
1131463
function checkTypeSelector(i) {
  if (i >= tokensLength) return 0;

  const start = i;
  let l;

  if (l = checkNamePrefix(i)) i += l;

  if (l = checkIdentOrInterpolation(i)) i += l;
  else return 0;

  return i - start;
}
1132216
function checkAtrule(i) {
  let l;

  if (i >= tokensLength) return 0;

  // If token already has a record of being part of an @-rule,
  // return the @-rule's length:
  if (tokens[i].atrule_l !== undefined) return tokens[i].atrule_l;

  // If token is part of an @-rule, save the rule's type to token.
  if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4;
  // @-rule with ruleset:
  else if (l = checkAtruler(i)) tokens[i].atrule_type = 1;
  // Block @-rule:
  else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2;
  // Single-line @-rule:
  else if (l = checkAtrules(i)) tokens[i].atrule_type = 3;
  else return 0;

  // If token is part of an @-rule, save the rule's length to token:
  tokens[i].atrule_l = l;

  return l;
}
1154176
function checkPseudoElement1(i) {
  const start = i;
  let l;

  // Skip `::`.
  i += 2;

  if (i >= tokensLength) return 0;

  if (l = checkIdent(i)) i += l;
  else return 0;

  if (i >= tokensLength ||
      tokens[i].type !== TokenType.LeftParenthesis) return 0;

  const right = tokens[i].right;

  // Skip `(`.
  i++;

  if (l = checkSC(i)) i += l;

  if (l = checkSelectorsGroup(i)) i += l;
  else return 0;

  if (l = checkSC(i)) i += l;

  if (i !== right) return 0;

  // Skip `)`.
  i++;

  return i - start;
}
827310
function checkInclude(i) {
  let l;

  if (i >= tokensLength) return 0;

  if (l = checkIncludeWithKeyframes1(i)) tokens[i].include_type = 9;
  else if (l = checkInclude1(i)) tokens[i].include_type = 1;
  else if (l = checkInclude2(i)) tokens[i].include_type = 2;
  else if (l = checkInclude3(i)) tokens[i].include_type = 3;
  else if (l = checkInclude4(i)) tokens[i].include_type = 4;
  else if (l = checkIncludeWithKeyframes2(i)) tokens[i].include_type = 10;
  else if (l = checkInclude5(i)) tokens[i].include_type = 5;
  else if (l = checkInclude6(i)) tokens[i].include_type = 6;
  else if (l = checkInclude7(i)) tokens[i].include_type = 7;
  else if (l = checkInclude8(i)) tokens[i].include_type = 8;

  return l;
}
957057
function isAlphaNumericAt(str, i)
{
    var code = str.charCodeAt(i);
    //        "0" <= code <= "9"           "A" <= code <= "Z"         "a" <= code <= "z"
    return ((code > 47 && code < 58) || (code > 64 && code < 91) || code > 96 && code < 123);
}
913016
function checkValue(i) {
  const start = i;
  let l;
  let s;
  let _i;

  while (i < tokensLength) {
    if (checkDeclDelim(i)) break;

    s = checkSC(i);
    _i = i + s;

    if (l = _checkValue(_i)) i += l + s;
    if (!l || checkBlock(i - l)) break;
  }

  tokens[start].value_end = i;

  return i - start;
}
614849
function _checkUnicodeWildcard(i) {
  const start = i;

  if (i >= tokensLength) return 0;

  while (i < tokensLength) {
    if (tokens[i].type === TokenType.QuestionMark) i += 1;
    else break;
  }

  return i - start;
}
917487
function checkAtkeyword(i) {
  let l;

  // Check that token is `@`:
  if (i >= tokensLength ||
      tokens[i++].type !== TokenType.CommercialAt) return 0;

  return (l = checkIdentOrInterpolation(i)) ? l + 1 : 0;
}
19255
function tokenizeEscape(match, value) {
    var index = tokenized.length;
    tokenized[index] = "'+\n_.escape(" + value + ") +\n'";
    return token + index;
  }