MCPcopy Create free account
hub / github.com/webpack/mini-css-extract-plugin / popCommonItems

Function popCommonItems

src/utils.js:285–315  ·  view source on GitHub ↗
(itemsSet, getKey, condition)

Source from the content-addressed store, hash-verified

283 * @returns {string[][]} list of common items
284 */
285const popCommonItems = (itemsSet, getKey, condition) => {
286 /** @type {Map<string, string[]>} */
287 const map = new Map();
288
289 for (const item of itemsSet) {
290 const key = getKey(item);
291 if (key) {
292 let list = map.get(key);
293 if (list === undefined) {
294 /** @type {string[]} */
295 list = [];
296 map.set(key, list);
297 }
298 list.push(item);
299 }
300 }
301
302 /** @type {string[][]} */
303 const result = [];
304
305 for (const list of map.values()) {
306 if (condition(list)) {
307 for (const item of list) {
308 itemsSet.delete(item);
309 }
310 result.push(list);
311 }
312 }
313
314 return result;
315};
316
317/**
318 * @param {string[]} itemsArr array of items

Callers 1

itemsToRegexpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…