diff --git a/src/async/impl.ts b/src/async/impl.ts index 86a1416..f7022f6 100644 --- a/src/async/impl.ts +++ b/src/async/impl.ts @@ -216,27 +216,29 @@ export abstract class BaseAsyncSequence extends AsyncSequenceMarker im } async #tryGetLast(predicate?: MaybeAsyncAnyPredicate): Promise> { - let found = false; - let result: TElement | undefined = undefined; + let result: FindElementResult = { + found: false + }; if (predicate) { for await (const element of this) { if (await predicate(element)) { - found = true; - result = element; + result = { + found: true, + element + }; } } } else { for await (const element of this) { - found = true; - result = element; + result = { + found: true, + element + }; } } - return { - found, - element: result - } as FindElementResult; + return result; } async last(predicate?: MaybeAsyncAnyPredicate) { @@ -1687,7 +1689,7 @@ class TakeAsyncSequence extends BaseAsyncSequence { return; } - yield next.value as T; + yield next.value; i--; } } diff --git a/src/equality-comparer/sync.ts b/src/equality-comparer/sync.ts index a073a11..c2670f5 100644 --- a/src/equality-comparer/sync.ts +++ b/src/equality-comparer/sync.ts @@ -2,15 +2,15 @@ import { Converter } from "../types.js"; import { Nullable } from "../utils.js"; import { EqualityComparer, EqualityComparison, EqualityComparisonOrComparer } from "./types.js"; -export function looseEquals(a: T, b: T) { +export function looseEquals(a: any, b: any) { return a == b; } -export function strictEquals(a: T, b: T) { +export function strictEquals(a: any, b: any) { return a === b; } -export function sameValue(a: T, b: T) { +export function sameValue(a: any, b: any) { return Object.is(a, b); } diff --git a/src/sync/impl.ts b/src/sync/impl.ts index a18ec51..312f2a6 100644 --- a/src/sync/impl.ts +++ b/src/sync/impl.ts @@ -225,27 +225,29 @@ export abstract class BaseSequence extends SequenceMarker implements S } #tryGetLast(predicate?: AnyPredicate): FindElementResult { - let found = false; - let result: TElement | undefined = undefined; + let result: FindElementResult = { + 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; + return result; } last(predicate?: AnyPredicate) {