refactor
This commit is contained in:
@@ -225,27 +225,29 @@ export abstract class BaseSequence<TElement> extends SequenceMarker implements S
|
||||
}
|
||||
|
||||
#tryGetLast(predicate?: AnyPredicate<TElement>): FindElementResult<TElement> {
|
||||
let found = false;
|
||||
let result: TElement | undefined = undefined;
|
||||
let result: FindElementResult<TElement> = {
|
||||
found: false
|
||||
};
|
||||
|
||||
if (predicate) {
|
||||
for (const element of this) {
|
||||
if (predicate(element)) {
|
||||
found = true;
|
||||
result = element;
|
||||
result = {
|
||||
found: true,
|
||||
element
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const element of this) {
|
||||
found = true;
|
||||
result = element;
|
||||
result = {
|
||||
found: true,
|
||||
element
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
found,
|
||||
element: result
|
||||
} as FindElementResult<TElement>;
|
||||
return result;
|
||||
}
|
||||
|
||||
last(predicate?: AnyPredicate<TElement>) {
|
||||
|
||||
Reference in New Issue
Block a user