collectype / factory/urls/urlState / urlStateFactory
urlStateFactory<
T,C>(ctx,oper): <K>(field) =>C
Defined in: factory/urls/urlState.ts:34
Creates a predicate filter for URL state checks using PredicType.url.state.
T
The item type in the collection.
C extends Wherable<T, C>
The Wherable context type (must extend Wherable<T, C>).
C
The context (usually a collection) supporting the where method.
UrlStateOper
The URL state operation to perform.
Returns a function that takes a URL field on T, evaluates its state, and filters the context.
<K>(field) => C
// Example based on sample/models/Person and sample/data/person
import { BaseFunctions, urlStateFactory } from 'collectype';
import { Person } from '../../../sample/models/Person';
import { people } from '../../../sample/data/person';
class PersonFunctions extends BaseFunctions<Person> {
urlIsHttps = urlStateFactory<Person, this>(this, 'is_https');
}
const fn = new PersonFunctions(people);
const filtered = fn.urlIsHttps('website');
// filtered contains people whose website uses HTTPS
URL are supported.PredicType.url.state.