UNPKG

@thi.ng/oquery

Version:

Datalog-inspired, optimized pattern/predicate query engine for JS objects & arrays of objects

46 lines 1.81 kB
import type { Nullable } from "@thi.ng/api"; import type { KeyQueryFn, KeyQueryOpts, MultiQueryOpts, QueryFn, QueryObj, QueryOpts, QueryTerm } from "./api.js"; /** * Generic Higher-order function to return an actual query function based on * given behavior options. * * @remarks * - {@link QueryOpts} * - {@link ObjQueryFn} * - {@link ArrayQueryFn} * - {@link defKeyQuery} * * @param opts - */ export declare const defQuery: <T extends QueryObj | QueryObj[] = QueryObj>(opts?: Partial<QueryOpts>) => QueryFn<T>; /** * Generic Higher-order function to return an actual query function based on * given behavior options. Unlike {@link defQuery}, key query functions only * return sets of keys (or indices) of matching objects. * * @remarks * - {@link KeyQueryOpts} * - {@link ObjKeyQueryFn} * - {@link ArrayKeyQueryFn} * * @param opts - */ export declare const defKeyQuery: <T extends QueryObj | QueryObj[] = QueryObj>(opts?: Partial<KeyQueryOpts>) => KeyQueryFn<T>; /** * Multi-term query function for collections (arrays) of {@link QueryObj}ects. * Takes a number of {@link QueryTerm}s and matches each term in succession * against the array of results of the previous terms (i.e. each sub-query is * potentially further narrowing the result set). Returns final results, * possibly post-processed, depending on given options. * * @remarks * Each {@link QueryTerm} can provide its own options and post-processing * function. Furthermore, global post-processing (e.g. limiting number of final * results, sorting by key) can be configured via `opts`. * * @param db * @param terms * @param opts */ export declare const query: <T extends QueryObj = QueryObj>(db: T[], terms: Nullable<QueryTerm<T>>[], opts?: Partial<MultiQueryOpts<T>>) => T[]; //# sourceMappingURL=query.d.ts.map