Utility functions to compare key ranges and determine super ranges in Dexie.js.
// Source: https://github.com/dexie/Dexie.js | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { cmp } from '../../functions/cmp';
import { DBCoreKeyRange } from '../../public/types/dbcore';
export function compareLowers(
lower1: any,
lower2: any,
lowerOpen1: boolean,
lowerOpen2: boolean
) {
if (lower1 === undefined) return lower2 !== undefined ? -1 : 0;
if (lower2 === undefined) return 1; // since lower1 !== undefined
const c = cmp(lower1, lower2);
if (c === 0) {
if (lowerOpen1 && lowerOpen2) return 0;
if (lowerOpen1) return 1;
if (lowerOpen2) return -1;
}
return c;
}
export function compareUppers(
upper1: any,
upper2: any,
upperOpen1:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key