@podlite/schema
Version:
AST tools for Podlite markup language
29 lines (24 loc) • 896 B
TypeScript
import { PodNode } from './types';
declare type Query = ((par: Object) => Boolean) | any;
/**
* compileQuery - compile a query to a function
Object as a parameter:
{'name':'head', level:[1,2,3,4]}
const checkObject = compileQuery({name:'head',level:2}, (item)=>item.name === 1);
Function as a parameter:
(item)=>item.name === 1
const checkObject2 = compileQuery((i)=>i.name == '1')
const r = checkObject([{name:'head', level:1},{name:'head', level:2},{name:'head', level:2}, {name:1, level:2}])
*
* @param obj
* @returns function that can be used to filter the objects
*/
export declare const compileQuery: (...obj: Query[]) => (any: any) => any;
/**
* Get nodes by queries
* @param tree
* @param queries
* @returns array of matched nodes
*/
export declare const getFromTree: (tree: any, ...queries: string[] | any) => PodNode[];
export {};