List » items
items() → array
items(options) → array
items(loader) → array
items(loader, options) → array
Retrieve the items of the list, optionally passing them through a loader function.
enocolors:
- pink
- peach
javascriptconst list = eno.parse(input).element('colors');
list.items(); // returns ['pink', 'peach']
list.items(({ value }) => `${value}!!`); // returns ['pink!!', 'peach!!']
Parameters
loaderA function returning the transformed/validated value or throwing an error. (The
function is applied to each list item on its own and is passed name
and
value
inside a single object parameter.
elements
Whether to return the elements (as Field
) instead of the values of the list items. (defaults to false
)
enforceValues
Whether empty list items (-
in the document, mapping to null
) are disallowed (defaults to true
)
withElements
Whether to return an array of objects of the form { element: ..., value: ... }
instead of just the values (defaults to false
)
Return value
The (optionally transformed/validated) items of this list as an array.