packages/babel-plugin-minify-builtins/src/index.js
function getSegmentedSubPaths(paths) {
    let segments = new Map();

    // Get earliest Path in tree where paths intersect
    paths[0].getDeepestCommonAncestorFrom(
      paths,
      (lastCommon, index, ancestries) => {
        // found the LCA
        if (!lastCommon.isProgram()) {
          let fnParent;
          if (
            lastCommon.isFunction() &&
            t.isBlockStatement(lastCommon.node.body)
          ) {
            segments.set(lastCommon, paths);
            return;
          } else if (
            !(fnParent = getFunctionParent(lastCommon)).isProgram() &&
            t.isBlockStatement(fnParent.node.body)
          ) {
            segments.set(fnParent, paths);
            return;
          }
        }
        // Deopt and construct segments otherwise
        for (const ancestor of ancestries) {
          const fnPath = getChildFuncion(ancestor);
          if (fnPath === void 0) {
            continue;
          }
          const validDescendants = paths.filter(p => {
            return p.isDescendant(fnPath);
          });
          segments.set(fnPath, validDescendants);
        }
      }
    );
    return segments;
  }
function getSegmentedSubPaths(paths) {
    let segments = new Map();

    // Get earliest Path in tree where paths intersect
    paths[0].getDeepestCommonAncestorFrom(
      paths,
      (lastCommon, index, ancestries) => {
        // found the LCA
        if (!lastCommon.isProgram()) {
          let fnParent;
          if (
            lastCommon.isFunction() &&
            t.isBlockStatement(lastCommon.node.body)
          ) {
            segments.set(lastCommon, paths);
            return;
          } else if (
            !(fnParent = getFunctionParent(lastCommon)).isProgram() &&
            t.isBlockStatement(fnParent.node.body)
          ) {
            segments.set(fnParent, paths);
            return;
          }
        }
        // Deopt and construct segments otherwise
        for (const ancestor of ancestries) {
          const fnPath = getChildFuncion(ancestor);
          if (fnPath === void 0) {
            continue;
          }
          const validDescendants = paths.filter(p => {
            return p.isDescendant(fnPath);
          });
          segments.set(fnPath, validDescendants);
        }
      }
    );
    return segments;
  }
function getSegmentedSubPaths ( paths ) { let segments = new Map ( ) ; // Get earliest Path in tree where paths intersect paths [ 0 ] . getDeepestCommonAncestorFrom ( paths , ( lastCommon , index , ancestries ) => { // found the LCA if ( ! lastCommon . isProgram ( ) ) { let fnParent ; if ( lastCommon . isFunction ( ) && t . isBlockStatement ( lastCommon . node . body ) ) { segments . set ( lastCommon , paths ) ; return ; } else if ( ! ( fnParent = getFunctionParent ( lastCommon ) ) . isProgram ( ) && t . isBlockStatement ( fnParent . node . body ) ) { segments . set ( fnParent , paths ) ; return ; } } // Deopt and construct segments otherwise for ( const ancestor of ancestries ) { const fnPath = getChildFuncion ( ancestor ) ; if ( fnPath === void 0 ) { continue ; } const validDescendants = paths . filter ( p => { return p . isDescendant ( fnPath ) ; } ) ; segments . set ( fnPath , validDescendants ) ; } } ) ; return segments ; }
Creates a segmented map that contains the earliest common Ancestor as the key and array of subpaths that are descendats of the LCA as value
Creates a segmented map that contains the earliest common Ancestor as the key and array of subpaths that are descendats of the LCA as value