MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / getCompatiblePlatforms

Function getCompatiblePlatforms

apps/site/util/download/archive.tsx:48–76  ·  view source on GitHub ↗
(
  platforms: Record<OperatingSystem, Array<DownloadDropdownItem<Platform>>>,
  exclude: Array<string>,
  versionWithPrefix: string
)

Source from the content-addressed store, hash-verified

46 * Filters platforms by compatibility and exclusions
47 */
48const getCompatiblePlatforms = (
49 platforms: Record<OperatingSystem, Array<DownloadDropdownItem<Platform>>>,
50 exclude: Array<string>,
51 versionWithPrefix: string
52) => {
53 return Object.entries(platforms).flatMap(([os, items]) => {
54 if (exclude.includes(os)) {
55 return [];
56 }
57
58 return items
59 .filter(({ compatibility }) => {
60 // In the download constants file (apps/site/util/download/constants.json),
61 // if no compatibility is defined as a semver, we treat it as supporting all
62 // versions by default.
63 if (!compatibility.semver) {
64 return true;
65 }
66
67 return compatibility.semver.every(version =>
68 semVer.satisfies(versionWithPrefix, version)
69 );
70 })
71 .map(platform => ({
72 os,
73 platform,
74 })) as CompatiblePlatforms;
75 });
76};
77
78/**
79 * Returns a list of compatible artifacts for the given options.

Callers 1

getCompatibleArtifactsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected