Skip to content

Commit

Permalink
chore: add filtering by type
Browse files Browse the repository at this point in the history
  • Loading branch information
azech-hqs committed Sep 13, 2023
1 parent ab845fd commit ccc21d5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/include/meta_properties/pseudopotential.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export class Pseudopotential extends Property {
filteredPseudos = this.filterByAppName(filteredPseudos, fValue);
} else if (fKey === "elements" && fValue) {
filteredPseudos = this.filterByElements(filteredPseudos, fValue);
} else if (fKey === "type" && fValue) {
filteredPseudos = this.filterByType(filteredPseudos, fValue);
}
});
return filteredPseudos;
Expand Down Expand Up @@ -161,4 +163,13 @@ export class Pseudopotential extends Property {
return 0;
});
}

/**
* @param {Pseudopotential[]} pseudos - Pseudopotentials to filter
* @param {string} pseudoType - Pseudopotential type (e.g. "us", "nc", ...)
* @returns {Pseudopotential[]}
*/
static filterByType(pseudos, pseudoType) {
return pseudos.filter((pseudo) => pseudo.type.includes(pseudoType));
}
}

0 comments on commit ccc21d5

Please sign in to comment.