mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[AAE-12146] Update getFeature typings (#8167)
* [AAE-11463] Update getFeature typings * added tests
This commit is contained in:
@@ -117,12 +117,13 @@ export class ExtensionService {
|
||||
/**
|
||||
* Gets features by key.
|
||||
*
|
||||
* @param key Key string, using dot notation
|
||||
* @returns Features array found by key
|
||||
* @param key Key string using dot notation or array of strings
|
||||
* @param defaultValue Default value returned if feature is not found, default is empty array
|
||||
* @returns Feature found by key
|
||||
*/
|
||||
getFeature(key: string): any[] {
|
||||
const properties: string[] = Array.isArray(key) ? [key] : key.split('.');
|
||||
return properties.reduce((prev, curr) => prev && prev[curr], this.features) || [];
|
||||
getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T {
|
||||
const properties: string[] = Array.isArray(key) ? key : key.split('.');
|
||||
return properties.reduce((prev, curr) => prev && prev[curr], this.features) || defaultValue;
|
||||
}
|
||||
|
||||
getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> {
|
||||
|
Reference in New Issue
Block a user