Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function generatePolyfillURL(features = []) {
const polyfillUrl = 'https://cdn.polyfill.io/v3/polyfill.min.js';
const aliases = await polyfillLibrary.listAliases();
const polyfills = await polyfillLibrary.listAllPolyfills();
const featuresInPolyfillLibrary = new Set;
for (const feature of features) {
if (polyfills.includes(feature)) {
featuresInPolyfillLibrary.add(feature);
} else if (feature in aliases) {
featuresInPolyfillLibrary.add(feature);
} else if (feature.includes('.prototype')) {
const featureConstructor = feature.split('.prototype')[0];
if (polyfills.includes(featureConstructor)) {
featuresInPolyfillLibrary.add(featureConstructor);
} else if (featureConstructor in aliases) {
featuresInPolyfillLibrary.add(featureConstructor);
}
}
}