1
0
This commit is contained in:
Herve BECHER
2025-09-26 10:40:46 +02:00
parent 5c847e4972
commit ecb6ad2c5f
3 changed files with 28 additions and 24 deletions

View File

@@ -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>) {