MCPcopy
hub / github.com/webpack/webpack / concatComparators

Function concatComparators

lib/util/comparators.js:436–458  ·  lib/util/comparators.js::concatComparators
(c1, c2, ...cRest)

Source from the content-addressed store, hash-verified

434 * @returns {Comparator<T>} comparator
435 */
436const concatComparators = (c1, c2, ...cRest) => {
437 if (cRest.length > 0) {
438 const [c3, ...cRest2] = cRest;
439 return concatComparators(c1, concatComparators(c2, c3, ...cRest2));
440 }
441 const cacheEntry = /** @type {Comparator<T>} */ (
442 concatComparatorsCache.get(c1, c2)
443 );
444 if (cacheEntry !== undefined) return cacheEntry;
445 /**
446 * Returns compare result.
447 * @param {T} a first value
448 * @param {T} b second value
449 * @returns {-1 | 0 | 1} compare result
450 */
451 const result = (a, b) => {
452 const res = c1(a, b);
453 if (res !== 0) return res;
454 return c2(a, b);
455 };
456 concatComparatorsCache.set(c1, c2, result);
457 return result;
458};
459
460/**
461 * Defines the selector type used by this module.

Callers 8

buildMethod · 0.85
handleParseResultMethod · 0.85
Compilation.jsFile · 0.85
_createMethod · 0.85
compareChunksNaturalFunction · 0.85

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected