Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 21x 7x 378x 126x 126x 126x 7x | /**
* Sorts manifests based on a 'recommended' list.
* It creates an empty array with empty slots
* to avoid calculating indexes multiple times;
* unused slots are filtered at the end.
*
* @param {Manifest} manifests
* @param {precision.cdns} recommendedCdns
**/
const mapToRecommendedCdns = (manifests, recommendedCdns = []) => {
const sortedManifests = manifests
.reduce((output, nextManifest) => {
const [recommended, notRecommended] = output;
const recommendedCdnIndex = recommendedCdns.indexOf(nextManifest.name);
recommendedCdnIndex > -1
? recommended.splice(recommendedCdnIndex, 1, nextManifest)
: notRecommended.push(nextManifest);
return output;
}, [Array(recommendedCdns.length),[]]);
const [recommended, notRecommended] = sortedManifests;
return recommended.concat(notRecommended).filter(Boolean);
};
export default mapToRecommendedCdns;
|