MCPcopy
hub / github.com/webpack/webpack / keepOriginalOrder

Function keepOriginalOrder

lib/util/comparators.js:515–527  ·  view source on GitHub ↗
(iterable)

Source from the content-addressed store, hash-verified

513 * @returns {Comparator<T>} comparator
514 */
515const keepOriginalOrder = (iterable) => {
516 /** @type {Map<T, number>} */
517 const map = new Map();
518 let i = 0;
519 for (const item of iterable) {
520 map.set(item, i++);
521 }
522 return (a, b) =>
523 compareNumbers(
524 /** @type {number} */ (map.get(a)),
525 /** @type {number} */ (map.get(b))
526 );
527};
528
529/**
530 * Compares chunks natural.

Callers 3

buildMethod · 0.85
handleParseResultMethod · 0.85
_createMethod · 0.85

Calls 3

compareNumbersFunction · 0.70
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected