packages/flow-remove-types/index.js
// Returns true if the provided token was previously marked as removed.
Returns true if the provided token was previously marked as removed.
Returns true if the provided token was previously marked as removed .
function isRemovedToken(context, token) {
  var removedNodes = context.removedNodes;
  var nodeIdx = removedNodes.length - 1;
  while (nodeIdx >= 0 && startOf(removedNodes[nodeIdx]) > startOf(token)) {
    nodeIdx--;
  }
  var node = removedNodes[nodeIdx];
  if (nodeIdx === -1 || endOf(node) < endOf(token)) {
    return false;
  }
  var tokens = context.ast.tokens;
  var tokenIdx = findTokenIndex(tokens, startOf(node));
  while (endOf(tokens[tokenIdx]) <= endOf(node)) {
    if (token === tokens[tokenIdx]) {
      return true;
    }
    tokenIdx++;
  }
  return false;
}
function isRemovedToken ( context , token ) { var removedNodes = context . removedNodes ; var nodeIdx = removedNodes . length - 1 ; while ( nodeIdx >= 0 && startOf ( removedNodes [ nodeIdx ] ) > startOf ( token ) ) { nodeIdx -- ; } var node = removedNodes [ nodeIdx ] ; if ( nodeIdx === - 1 || endOf ( node ) < endOf ( token ) ) { return false ; } var tokens = context . ast . tokens ; var tokenIdx = findTokenIndex ( tokens , startOf ( node ) ) ; while ( endOf ( tokens [ tokenIdx ] ) <= endOf ( node ) ) { if ( token === tokens [ tokenIdx ] ) { return true ; } tokenIdx ++ ; } return false ; }
Returns true if the provided token was previously marked as removed.
Returns true if the provided token was previously marked as removed .
// Find the last removed node which could possibly contain this token. // This token couldn't be removed if not contained within the removed node. // Iterate through the tokens contained by the removed node to find a match.