Given a set of bundles, merge until no main module needs to fetch from more
than maxBundles number of bundles.
769181
function reduceBundles(bundles, dependencies, maxBundles) {
    while (anyMainExceedsMaxBundles(bundles, maxBundles)) {
        var merge = findLeastCostMerge(bundles, dependencies, maxBundles);
        mergeBundles(merge.bundle1Name, merge.bundle2Name, bundles);
    }
    return bundles;
}
6512
private static void harvestPackageList(BundlePackages packages, Bundle bundle) {
        // Double check that the bundle is (still) installed:
        if (bundle.getLocation() != null && bundle.getState() != Bundle.UNINSTALLED) {
            BundleManifest manifest = new BundleManifest(bundle);
            /*
             * Only bundles with a bundle vendor of IBM should count as internal.
             * We definitely don't want to be filtering out user bundles in the shared bundle space.
             * This filter might catch stack products, which is probably a good thing
             * if it happens.
             * We also want to count the system bundle as internal. Some of
             * the bundles with higher IDs aren't ours, but since we rebuild them
             * with bnd, they get an IBM vendor header.
             */
            if (bundle.getBundleId() == 0 || IBM.equals(manifest.getBundleVendor()) || IBM.equals(manifest.getBundleDistributor())) {
                packages.addPackages(manifest);
            }
        }
    }
849141
public static void flushBundleCache(String baseName, boolean flushPermanent) {

        if (baseName != null) {
            synchronized (m_bundleCache) {

                // first check and clear the bundle cache
                Map<BundleKey, ResourceBundle> bundleCacheNew = new ConcurrentHashMap<BundleKey, ResourceBundle>(
                    m_bundleCache.size());
                for (Map.Entry<BundleKey, ResourceBundle> entry : m_bundleCache.entrySet()) {
                    if (!entry.getKey().isSameBase(baseName)) {
                        // entry has a different base name, keep it
                        bundleCacheNew.put(entry.getKey(), entry.getValue());
                    }
                }
                if (bundleCacheNew.size() < m_bundleCache.size()) {
                    // switch caches if only if at least one entry was removed
                    m_bundleCache = bundleCacheNew;
                }
                if (flushPermanent) {
                    flushPermanentCache(baseName);
                }
            }
        }
    }
727276
public void storeBundle(String bundleName, StringBuffer bundledResources) {

		JoinableResourceBundleContent bundleResourcesContent = new JoinableResourceBundleContent(bundledResources);
		storeBundle(bundleName, bundleResourcesContent);
	}
366918
@Override
	protected List<JoinableResourceBundle> filterBundlesToRender(List<JoinableResourceBundle> bundles) {
		List<JoinableResourceBundle> filteredBundles = new ArrayList<>();
		for (JoinableResourceBundle bundle : bundles) {
			if (bundle.getInclusionPattern().isIncludeOnDebug()) {
				filteredBundles.add(bundle);
			}
		}
		return filteredBundles;
	}
1236738
private void mergeForceCollapse() {
        while (stackSize > 1) {
            int n = stackSize - 2;
            if (n > 0 && runLen[n - 1] < runLen[n + 1])
                n--;
            mergeAt(n);
        }
    }
126443
@Override
	public void rebuildDirtyBundles() {
		if (jsMBean != null) {
			jsMBean.rebuildDirtyBundles();
		}
		if (cssMBean != null) {
			cssMBean.rebuildDirtyBundles();
		}
		if (binaryMBean != null) {
			binaryMBean.rebuildDirtyBundles();
		}
	}
1072474
function bundler(loader, options, modules) {
  var stack    = modules.slice(0);
  var mods     = [];
  var finished = {};

  function processModule(mod) {
    if (finished.hasOwnProperty(mod.id)) {
      return;
    }

    mod = loader.getModule(mod.id);

    // browser pack chunk
    var browserpack = {
      id     : mod.id,
      source : mod.source,
      deps   : {}
    };

    // Gather up all dependencies
    var i, length, dep;
    for (i = 0, length = mod.deps.length; i < length; i++) {
      dep = mod.deps[i];
      stack.push(dep);
      browserpack.deps[dep.id] = dep.id;
    }

    finished[mod.id] = browserpack;
    mods.unshift(browserpack);
  }

  // Process all modules
  while (stack.length) {
    processModule(stack.pop());
  }

  var stream = browserPack(options).setEncoding("utf8");
  var promise = pstream(stream);

  stream.end(JSON.stringify(mods));
  return promise;
}
940264
def ParseMultiple(self, result_dicts):
    """"""
    status = rdf_client.SoftwarePackage.InstallState.INSTALLED
    packages = []
    for result_dict in result_dicts:
      packages.append(
          rdf_client.SoftwarePackage(
              name=result_dict["Name"],
              description=result_dict["Description"],
              version=result_dict["Version"],
              install_state=status))

    if packages:
      yield rdf_client.SoftwarePackages(packages=packages)
1024394
function mergeIntoMasterAndAddBundle(opts) {
	var mains = opts.mains;
	var loader = opts.loader;
	var newGraph = opts.newGraph;
	var bundleName = opts.bundleName;
	var masterGraph = opts.masterGraph;

	for(var name in newGraph) {
		var oldNode = masterGraph[name];
		var newNode = newGraph[name];

		if(!oldNode || hasNewDeps(oldNode, newNode)) {
			masterGraph[name] = newGraph[name];
		}
		// If it's a plugin we'll use the new node but need to copy any previous
		// bundles onto the new node
		else if(masterGraph[name] && masterGraph[name].isPlugin) {
			var oldBundle = masterGraph[name].bundles || [];
			masterGraph[name] = newGraph[name];
			oldBundle.forEach(function(bundle){
				addBundle(masterGraph[name], bundle);
			});
		}
		// If this is the configMain like package.json!npm we need to override
		// the source every time because it continuously changes.
		else if(masterGraph[name] && name === loader.configMain) {
			var node = masterGraph[name];
			node.load.source = newGraph[name].load.source;
		}

		// do not track bundles of entry point modules (a.k.a mains) unless
		// it is its own bundle.
		if (name === bundleName || !includes(mains, name)) {
			addBundle(masterGraph[name], bundleName);
		}
	}
}
805907
function pruneModules(bundle, doneBundles, registry, generator) {
    const {groups} = generator.options;
    groups.forEach(group => {
        const bundles = group.map(bundleId => {
            return doneBundles.find(b => b.id === bundleId);
        }).filter(Boolean);
        pruneGroup(bundles);
    });
}
739353
function Multibundle(config, components)
{
  var tasks;

  if (!(this instanceof Multibundle))
  {
    return new Multibundle(config, components);
  }

  // turn on object mode
  Readable.call(this, {objectMode: true});

  // prepare config options
  this.config = lodash.merge({}, Multibundle._defaults, config);
  this.config.componentOptions = lodash.cloneDeep(components);

  // process each component in specific order
  tasks = this._getComponents()
    .map(this._processComponent.bind(this))
    .map(this._prepareForRjs.bind(this))
    ;

  // run optimize tasks asynchronously
  async.parallelLimit(tasks, this.config.parallelLimit, function(err)
  {
    if (err)
    {
      this.emit('error', err);
      return;
    }

    // be nice
    if (this.config.logLevel < 4)
    {
      console.log('\n-- All requirejs bundles have been processed.');
    }

    // singal end of the stream
    this.push(null);
  }.bind(this));
}
1009048
def _combine_sets(self, sets, final_set):
        
        self.cls.get_connection().sinterstore(final_set, list(sets))
        return final_set
431143
def new_bundle(name, scriptmap, filemap=None):

    """"""

    #logger.debug('new bundle %s' % name)
    if name in BUNDLEMAP:
        logger.warn('overwriting bundle %s' % name)
    BUNDLEMAP[name] = Bundle(scriptmap, filemap)
238770
def get_card_bundles(provider: Provider, deck: Deck) -> Generator:
    ''''''

    bundles = find_card_bundles(provider, deck)

    with concurrent.futures.ThreadPoolExecutor(max_workers=2) as th:
        for result in th.map(card_bundle_parser, bundles):
            if result:
                yield result
717135
def clean(bundle, before, after, keep_last):
    
    bundles_module.clean(
        bundle,
        before,
        after,
        keep_last,
    )
1353954
private void initResourceBundles(List<JoinableResourceBundle> resourceBundles)
			throws DuplicateBundlePathException, BundleDependencyException {

		// Create custom defined bundles
		bundleDefinitionsWithDependencies = new HashSet<>();
		if (null != bundleDefinitions) {
			if (LOGGER.isInfoEnabled())
				LOGGER.info("Adding custom bundle definitions. ");
			for (ResourceBundleDefinition def : bundleDefinitions) {
				// If this is a composite bundle
				if (def.isComposite()) {
					resourceBundles.add(buildCompositeResourcebundle(def));
				} else
					resourceBundles.add(buildResourcebundle(def));
			}
		}

		// Normalize the base Dir if needed
		if (!jawrConfig.getGeneratorRegistry().isPathGenerated(baseDir)) {
			this.baseDir = PathNormalizer.asDirPath(baseDir);
		}

		// Use the dirmapper if specified
		if (useDirMapperFactory) {
			if (LOGGER.isInfoEnabled())
				LOGGER.info("Using ResourceBundleDirMapper. ");

			ResourceBundleDirMapper dirFactory = new ResourceBundleDirMapper(baseDir, resourceReaderHandler,
					resourceBundles, fileExtension, excludedDirMapperDirs);
			Map<String, String> mappings = dirFactory.getBundleMapping();
			for (Entry<String, String> entry : mappings.entrySet()) {
				resourceBundles.add(buildDirMappedResourceBundle(entry.getKey(), entry.getValue()));
			}
		}

		if (this.scanForOrphans) {
			// Add all orphan bundles
			OrphanResourceBundlesMapper orphanFactory = new OrphanResourceBundlesMapper(baseDir, resourceReaderHandler,
					jawrConfig.getGeneratorRegistry(), resourceBundles, fileExtension);
			List<String> orphans = orphanFactory.getOrphansList();

			// Orphans may be added separately or as one single resource bundle.
			if (useSingleResourceFactory) {
				// Add extension to the filename
				if (!singleFileBundleName.endsWith(fileExtension))
					singleFileBundleName += fileExtension;

				if (LOGGER.isInfoEnabled())
					LOGGER.info("Building bundle of orphan resources with the name: " + singleFileBundleName);

				resourceBundles.add(buildOrphansResourceBundle(singleFileBundleName, orphans));

			} else {
				if (LOGGER.isInfoEnabled())
					LOGGER.info("Creating mappings for orphan resources. ");
				for (Iterator<String> it = orphans.iterator(); it.hasNext();) {
					resourceBundles.add(buildOrphanResourceBundle(it.next()));
				}
			}
		} else if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Skipping orphan file auto processing. ");
			if ("".equals(jawrConfig.getServletMapping()))
				LOGGER.debug("Note that there is no specified mapping for Jawr "
						+ "(it has been seet to serve *.js or *.css requests). "
						+ "The orphan files will become unreachable through the server.");
		}

		// Initialize bundle dependencies
		for (ResourceBundleDefinition definition : bundleDefinitionsWithDependencies) {
			JoinableResourceBundle bundle = getBundleFromName(definition.getBundleName(), resourceBundles);
			if (bundle != null) {
				bundle.setDependencies(getBundleDependencies(definition, resourceBundles));
			}
		}
	}