Skip to content

Commit

Permalink
Merge branch 'argh'
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoecklein committed Jul 28, 2023
2 parents 8eb8c07 + b1f4c81 commit 9644e61
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/cursorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ON_ERROR, ON_SUCCESS } from "./eventTypes.ts";
export function cursorHandler(
request: IDBRequest<IDBCursorWithValue | null> | IDBRequest<IDBCursor | null>,
iterator: (
cursor: IDBCursorWithValue,
) => boolean | void | Promise<boolean | void>,
export function cursorHandler<Cursor extends IDBCursor>(
request: IDBRequest<Cursor | null>,
iterator: (cursor: Cursor) => boolean | void | Promise<boolean | void>,
onEnd?: () => void,
onError?: (reason?: unknown) => void,
): Promise<void> {
Expand All @@ -23,7 +21,7 @@ export function cursorHandler(

// deno-lint-ignore no-explicit-any
request[ON_SUCCESS] = async (event: any) => {
const cursor = event.target?.result as IDBCursorWithValue;
const cursor = event.target?.result as Cursor;
if (cursor && !ended) {
ended = await iterator?.(cursor) ?? false;
if (ended === true) {
Expand Down

0 comments on commit 9644e61

Please sign in to comment.