@@ -323,14 +323,16 @@ const functionMap = {
323
323
* @typedef {object } ConfigSetting
324
324
* @property {'undefined' | 'number' | 'string' | 'function' | 'boolean' | 'null' | 'array' | 'object' } type
325
325
* @property {string } [functionName]
326
- * @property {boolean | string | number } value
326
+ * @property {* } [value] - Any value type (string, number, boolean, object, array, null, undefined)
327
+ * @property {ConfigSetting } [functionValue] - For function type, the value to return from the function
328
+ * @property {boolean } [async] - Whether to wrap the value in a Promise
327
329
* @property {object } [criteria]
328
- * @property {string } criteria.arch
330
+ * @property {string } [ criteria.arch]
329
331
*/
330
332
331
333
/**
332
334
* Processes a structured config setting and returns the value according to its type
333
- * @param {ConfigSetting } configSetting
335
+ * @param {ConfigSetting | ConfigSetting[] } configSetting
334
336
* @param {* } [defaultValue]
335
337
* @returns
336
338
*/
@@ -343,10 +345,12 @@ export function processAttr(configSetting, defaultValue) {
343
345
switch ( configSettingType ) {
344
346
case 'object' :
345
347
if ( Array . isArray ( configSetting ) ) {
346
- configSetting = processAttrByCriteria ( configSetting ) ;
347
- if ( configSetting === undefined ) {
348
+ const selectedSetting = processAttrByCriteria ( configSetting ) ;
349
+ if ( selectedSetting === undefined ) {
348
350
return defaultValue ;
349
351
}
352
+ // Now process the selected setting as a single ConfigSetting
353
+ return processAttr ( selectedSetting , defaultValue ) ;
350
354
}
351
355
352
356
if ( ! configSetting . type ) {
@@ -357,12 +361,22 @@ export function processAttr(configSetting, defaultValue) {
357
361
if ( configSetting . functionName && functionMap [ configSetting . functionName ] ) {
358
362
return functionMap [ configSetting . functionName ] ;
359
363
}
364
+ if ( configSetting . functionValue ) {
365
+ const functionValue = configSetting . functionValue ;
366
+ // Return a function that processes the functionValue using processAttr
367
+ return ( ) => processAttr ( functionValue , undefined ) ;
368
+ }
360
369
}
361
370
362
371
if ( configSetting . type === 'undefined' ) {
363
372
return undefined ;
364
373
}
365
374
375
+ // Handle async wrapping for all types including arrays
376
+ if ( configSetting . async ) {
377
+ return DDGPromise . resolve ( configSetting . value ) ;
378
+ }
379
+
366
380
// All JSON expressable types are handled here
367
381
return configSetting . value ;
368
382
default :
0 commit comments