diff --git a/src/utilities/RegistryFilter.ts b/src/utilities/RegistryFilter.ts index bf331a5..e4472ec 100644 --- a/src/utilities/RegistryFilter.ts +++ b/src/utilities/RegistryFilter.ts @@ -408,6 +408,18 @@ class RegistryFilter { return fork.entries.filter((entry, index) => fork.filters.every((filter) => filter(entry, index))); } + /** + * Retrieves an array of values for a specified property from the filtered entries. + * + * @param {keyof T} propertyName - The name of the property whose values are to be retrieved. + * @returns {Array} An array of values corresponding to the specified property. + * If the property does not exist in any entry, those entries will be filtered out. + */ + getValuesByProperty(propertyName: keyof T): Array { + const entries = this.toList(); // Call toList to get the full entries + return entries.map((entry) => entry[propertyName]).filter((value) => value !== undefined) as Array; + } + /** * Applies all the accumulated filters to the entries and returns the first remaining entry. *