lib/utils.js
function findPossibleIndexes(code, identifiers, filter) {
  const possibleIndexes = [];

  if (identifiers.length === 0) {
    return possibleIndexes;
  }

  const pattern = new RegExp(
    "\\b(?:" + identifiers.join("|") + ")\\b",
    "g"
  );

  let match;
  pattern.lastIndex = 0;
  while ((match = pattern.exec(code))) {
    if (typeof filter !== "function" || filter(match)) {
      possibleIndexes.push(match.index);
    }
  }

  return possibleIndexes;
}
function findPossibleIndexes(code, identifiers, filter) {
  const possibleIndexes = [];

  if (identifiers.length === 0) {
    return possibleIndexes;
  }

  const pattern = new RegExp(
    "\\b(?:" + identifiers.join("|") + ")\\b",
    "g"
  );

  let match;
  pattern.lastIndex = 0;
  while ((match = pattern.exec(code))) {
    if (typeof filter !== "function" || filter(match)) {
      possibleIndexes.push(match.index);
    }
  }

  return possibleIndexes;
}
function findPossibleIndexes ( code , identifiers , filter ) { const possibleIndexes = [ ] ; if ( identifiers . length === 0 ) { return possibleIndexes ; } const pattern = new RegExp ( "\\b(?:" + identifiers . join ( "|" ) + ")\\b" , "g" ) ; let match ; pattern . lastIndex = 0 ; while ( ( match = pattern . exec ( code ) ) ) { if ( typeof filter !== "function" || filter ( match ) ) { possibleIndexes . push ( match . index ) ; } } return possibleIndexes ; }
Returns a sorted array of possible indexes within the code string where any identifier in the identifiers array might appear. This information can be used to optimize AST traversal by allowing subtrees to be ignored if they don't contain any possible indexes.
Returns a sorted array of possible indexes within the code string where any identifier in the identifiers array might appear . This information can be used to optimize AST traversal by allowing subtrees to be ignored if they don t contain any possible indexes .