lib/simplifyExpression/stepThrough.js
// Returns a list of details about each step.
Returns a list of details about each step.
Returns a list of details about each step .
function stepThrough(node, debug=false) {
  if (debug) {
    console.log('\n\nSimplifying: ' + print.ascii(node, false, true));
  }
  if (checks.hasUnsupportedNodes(node)) {
    return [];
  }
  let nodeStatus;
  const steps = [];
  const originalExpressionStr = print.ascii(node);
  const MAX_STEP_COUNT = 20;
  let iters = 0;
  nodeStatus = step(node);
  while (nodeStatus.hasChanged()) {
    if (debug) {
      logSteps(nodeStatus);
    }
    steps.push(removeUnnecessaryParensInStep(nodeStatus));
    node = Status.resetChangeGroups(nodeStatus.newNode);
    nodeStatus = step(node);
    if (iters++ === MAX_STEP_COUNT) {
      console.error('Math error: Potential infinite loop for expression: ' +
                    originalExpressionStr + ', returning no steps');
      return [];
    }
  }
  return steps;
}
function stepThrough ( node , debug = false ) { if ( debug ) { console . log ( '\n\nSimplifying: ' + print . ascii ( node , false , true ) ) ; } if ( checks . hasUnsupportedNodes ( node ) ) { return [ ] ; } let nodeStatus ; const steps = [ ] ; const originalExpressionStr = print . ascii ( node ) ; const MAX_STEP_COUNT = 20 ; let iters = 0 ; nodeStatus = step ( node ) ; while ( nodeStatus . hasChanged ( ) ) { if ( debug ) { logSteps ( nodeStatus ) ; } steps . push ( removeUnnecessaryParensInStep ( nodeStatus ) ) ; node = Status . resetChangeGroups ( nodeStatus . newNode ) ; nodeStatus = step ( node ) ; if ( iters ++ === MAX_STEP_COUNT ) { console . error ( 'Math error: Potential infinite loop for expression: ' + originalExpressionStr + ', returning no steps' ) ; return [ ] ; } } return steps ; }
Returns a list of details about each step.
Returns a list of details about each step .
// eslint-disable-next-line // Now, step through the math expression until nothing changes // eslint-disable-next-line