find ()
Returns the value of the first item from a list that satisfies the test implemented by the specified function.
Parameters
$list
- The list from which items will be tested.
- Type
List
$predicate
- The function that tests each item for a condition. The first parameter is the current item being processed in the list. The second parameter is the index of the current item being processed in the list. The third parameter is the list being processed. The returned value will be compared for truthiness.
- Type
Function
$args
- Additional parameters which are provided to predicate function.
- Type
ArgList<*>
- Default
()
Return Value
List | Null
- The value of the first item in the list that satisfies the test provided by the predicate function; otherwise,
null
.
Example
@use 'sass:meta';
@use '@sass-fairy/list';
@function _greater-than-fifty($item, $void...) {
@return $item > 50;
}
$list: 32 8 65 79 34 8 13 66 18;
@debug list.find($list, meta.get-function('_greater-than-fifty'));
// 65