Debian Codegraph @

packages/babel-preset-env/src/filter-items.ts

raw symbols SCIP
1 import semver from "semver";
2 import { minVersions } from "./available-plugins";
3
4 const has = Function.call.bind(Object.hasOwnProperty);
5
6 export function addProposalSyntaxPlugins(
7 items: Set<string>,
8 proposalSyntaxPlugins: readonly string[],
9 ) {
10 proposalSyntaxPlugins.forEach(plugin => {
11 items.add(plugin);
12 });
13 }
14 export function removeUnnecessaryItems(
15 items: Set<string>,
16 overlapping: { [name: string]: string[] },
17 ) {
18 items.forEach(item => {
19 overlapping[item]?.forEach(name => items.delete(name));
20 });
21 }
22 export function removeUnsupportedItems(
23 items: Set<string>,
24 babelVersion: string,
25 ) {
26 items.forEach(item => {
27 if (
28 has(minVersions, item) &&
29 semver.lt(
30 babelVersion,
31 // @ts-expect-error we have checked minVersions[item] in has call
32 minVersions[item],
33 )
34 ) {
35 items.delete(item);
36 }
37 });
38 }