MCPcopy
hub / github.com/unpkg/unpkg / resolvePackageVersion

Function resolvePackageVersion

packages/unpkg-worker/src/lib/pkg-version.ts:5–21  ·  view source on GitHub ↗
(packageInfo: PackageInfo, versionRangeOrTag: string)

Source from the content-addressed store, hash-verified

3import type { PackageInfo } from "./npm-info.ts";
4
5export function resolvePackageVersion(packageInfo: PackageInfo, versionRangeOrTag: string): string | null {
6 let tags = packageInfo["dist-tags"];
7 if (tags != null && versionRangeOrTag in tags) {
8 return tags[versionRangeOrTag];
9 }
10
11 if (packageInfo.versions == null) return null;
12
13 let versions = Object.keys(packageInfo.versions);
14 if (valid(versionRangeOrTag) && versions.includes(versionRangeOrTag)) {
15 return versionRangeOrTag;
16 }
17
18 let max = maxSatisfying(versions, versionRangeOrTag);
19
20 return max === null ? null : max;
21}

Callers 4

handleRequestFunction · 0.90
handleRequestFunction · 0.90
resolveDependencyVersionFunction · 0.90
handleRequestFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected