philomena/assets/js/query/boolean.ts
liamwhite 3590be1429
match_query: unit test and rewrite for TypeScript (#208)
* match_query: unit test and rewrite for TypeScript

* match_query: use new type for parse errors

* match_query: avoid exceptional control flow in date parsing
2024-03-18 08:20:47 -04:00

17 lines
483 B
TypeScript

import { AstMatcher } from './types';
export function matchAny(...matchers: AstMatcher[]): AstMatcher {
return (e: HTMLElement) => matchers.some(matcher => matcher(e));
}
export function matchAll(...matchers: AstMatcher[]): AstMatcher {
return (e: HTMLElement) => matchers.every(matcher => matcher(e));
}
export function matchNot(matcher: AstMatcher): AstMatcher {
return (e: HTMLElement) => !matcher(e);
}
export function matchNone(): AstMatcher {
return () => false;
}