Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/component/btree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ export async function atOffsetHandler(
ctx: { db: DatabaseReader },
args: { offset: number; k1?: Key; k2?: Key; namespace?: Namespace }
) {
if (args.offset < 0) {
throw new Error("offset must be non-negative");
}
if (args.offset !== Math.floor(args.offset)) {
throw new Error("offset must be an integer");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use Number.isInteger

const tree = await getTree(ctx.db, args.namespace);
if (tree === null) {
throw new ConvexError("tree is empty");
Expand All @@ -394,6 +400,12 @@ export async function atNegativeOffsetHandler(
ctx: { db: DatabaseReader },
args: { offset: number; k1?: Key; k2?: Key; namespace?: Namespace }
) {
if (args.offset < 0) {
throw new Error("offset must be non-negative");
}
if (args.offset !== Math.floor(args.offset)) {
throw new Error("offset must be an integer");
}
const tree = await getTree(ctx.db, args.namespace);
if (tree === null) {
throw new ConvexError("tree is empty");
Expand Down
Loading