Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the extractSetOfValueSetsFromLibrary function in CodeService.js… #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/CodeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class CodeService {
} else if (results.length === 1) {
return results[0];
} else {
return results.reduce(function (a, b) {
return results.reduce(function(a, b) {
if (a.version > b.version) {
return a;
} else {
Expand All @@ -233,8 +233,20 @@ function extractSetOfValueSetsFromLibrary(
extractFromIncluded = true,
valueSets = new Set()
) {
// First add all the value sets from this library into the set
Object.values(library.valuesets).forEach(vs => valueSets.add(vs));
// Some JSON-ELM use the "valueSets" property, while others use the "valuesets" property
// First, check if library has "valueSets" property or "valuesets" property
if (library.valueSets == null && library.valuesets == null) {
return valueSets;
}

// Extract the arrays of the "valueSets" property and "valuesets" property
let valueSetsInLibrary = library.valueSets ? Object.values(library.valueSets)[0] : [];
let valuesetsInLibrary = library.valuesets ? Object.values(library.valuesets)[0] : [];

// Add all the value sets from this library into the set
valueSetsInLibrary.forEach(vs => valueSets.add(vs));
valuesetsInLibrary.forEach(vs => valueSets.add(vs));

// Then, if requested, loop through the included libraries and add value sets from each of them
if (extractFromIncluded && library.includes) {
Object.values(library.includes).forEach(included =>
Expand Down
Loading