MCPcopy
hub / github.com/github/docs / getFeaturesByVersion

Function getFeaturesByVersion

middleware/contextualizers/features.js:22–49  ·  view source on GitHub ↗
(currentVersion)

Source from the content-addressed store, hash-verified

20
21const cache = new Map()
22function getFeaturesByVersion(currentVersion) {
23 if (!cache.has(currentVersion)) {
24 if (!allFeatures) {
25 // As of Oct 2022, the `data/features/**` reading is *not* JIT.
26 // The `data/features` is deliberately not ignored in nodemon.json.
27 // See internal issue #2389
28 allFeatures = getDeepDataByLanguage('features', 'en')
29 }
30
31 const features = {}
32 // Determine whether the currentVersion belongs to the list of versions the feature is available in.
33 for (const [featureName, feature] of Object.entries(allFeatures)) {
34 const { versions } = feature
35 const applicableVersions = getApplicableVersions(
36 versions,
37 path.join(ROOT, `data/features/${featureName}.yml`)
38 )
39
40 // Adding the resulting boolean to the context object gives us the ability to use
41 // `{% if featureName ... %}` conditionals in content files.
42 const isFeatureAvailableInCurrentVersion = applicableVersions.includes(currentVersion)
43 features[featureName] = isFeatureAvailableInCurrentVersion
44 }
45 cache.set(currentVersion, features)
46 }
47
48 return cache.get(currentVersion)
49}

Callers 1

featuresFunction · 0.85

Calls 1

getApplicableVersionsFunction · 0.85

Tested by

no test coverage detected