src/optimizer/transforms/char-class-to-meta-transform.js
function rewriteWhitespaceRanges(path) {
  const {node} = path;

  let spacePath = null;
  let tPath = null;
  let nPath = null;
  let rPath = null;
  let fPath = null;

  node.expressions.forEach((expression, i) => {

    // Space
    if (isChar(expression, ' ')) {
      spacePath = path.getChild(i);
    }

    // \t
    else if (isMetaChar(expression, '\\t')) {
      tPath = path.getChild(i);
    }

    // \n
    else if (isMetaChar(expression, '\\n')) {
      nPath = path.getChild(i);
    }

    // \r
    else if (isMetaChar(expression, '\\r')) {
      rPath = path.getChild(i);
    }

    // \f
    else if (isMetaChar(expression, '\\f')) {
      fPath = path.getChild(i);
    }

  });

  // If we found the whole pattern, replace it.
  // Make \f optional.
  if (
    spacePath &&
    tPath &&
    nPath &&
    rPath
  ) {

    // Put \s in place of \n.
    nPath.node.value = '\\s';

    // Other paths are removed.
    spacePath.remove();
    tPath.remove();
    rPath.remove();

    if (fPath) {
      fPath.remove();
    }
  }
}
function rewriteWhitespaceRanges(path) {
  const {node} = path;

  let spacePath = null;
  let tPath = null;
  let nPath = null;
  let rPath = null;
  let fPath = null;

  node.expressions.forEach((expression, i) => {

    // Space
    if (isChar(expression, ' ')) {
      spacePath = path.getChild(i);
    }

    // \t
    else if (isMetaChar(expression, '\\t')) {
      tPath = path.getChild(i);
    }

    // \n
    else if (isMetaChar(expression, '\\n')) {
      nPath = path.getChild(i);
    }

    // \r
    else if (isMetaChar(expression, '\\r')) {
      rPath = path.getChild(i);
    }

    // \f
    else if (isMetaChar(expression, '\\f')) {
      fPath = path.getChild(i);
    }

  });

  // If we found the whole pattern, replace it.
  // Make \f optional.
  if (
    spacePath &&
    tPath &&
    nPath &&
    rPath
  ) {

    // Put \s in place of \n.
    nPath.node.value = '\\s';

    // Other paths are removed.
    spacePath.remove();
    tPath.remove();
    rPath.remove();

    if (fPath) {
      fPath.remove();
    }
  }
}
Rewrites whitespace ranges: [ \t\r\n\f] -> \s.