Skip to content

Commit

Permalink
Feat(flodash/find): added generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Jun 25, 2023
1 parent 40a101e commit 3719c2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
7 changes: 1 addition & 6 deletions commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@ rules:
- Wip
type-empty:
- 1
- never
scope-enum:
- 2
- always
- - flodash
- enhanced-http
- never
17 changes: 10 additions & 7 deletions packages/flodash/lib/modules/collection/find.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import '../../_utils/_array.dart';

@Deprecated("Use inbuilt List.firstWhere() instead")
dynamic find(List list, dynamic iteratee) {
try {
return list.firstWhere((element) => evaluatePredicate(iteratee, element));
} catch (e) {
return null;
}
/// Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with the value of the current item.
/// Arguments
/// - list (List): The collection to inspect.
/// - [iteratee] (dynamic): The iteratee invoked per iteration.
///
/// Returns
/// (T?): Returns the matched element, else null.
T? find<T>(List<T> list, dynamic iteratee) {
return list.firstWhere((element) => evaluatePredicate(iteratee, element),
orElse: () => null);
}

0 comments on commit 3719c2c

Please sign in to comment.