QueryParam

Represents some sort of API param that is embedded in a URL

new QueryParam(match_func: function, display: string?, validate_func: function?)
Parameters
match_func (function) a function that takes a url and returns the api param
display (string?) pretty name of this param to display
validate_func (function?) is the value valid
Example
const ParamSearch = new QueryParam(
     (v) => (`where name = '${v}'`), 
     'Search',
     (v) => /(\D+)/.test(v))
const ParamID = new QueryParam((v) => (`where id = ${v}`), null, null)
Instance Members
match(value)
validate(value)

QueryEnumParam

An enumerated QueryParam that can only have one value

new QueryEnumParam(key: string, match_func: function, display: string?)

Extends QueryParam

Parameters
key (string) the exact value of the param
match_func (function) a function that takes a url and returns the api param
display (string?) pretty name of this param to display
Example
const ParamSortName = new QueryEnumParam(
     'abc', 
     () => ('order by name'),
     'by Name', )
const ParamSortPop = new QueryEnumParam(
'pop', 
() => ('order by count desc'), 
'by Popularity')

Location

Base object to inherit from

new Location(href: string, config: object)
Parameters
href (string) the instance href of the location
config (object = {})
Name Description
config.debug bool (default true) extra debug info
config.log func (default console.log) debug logging func
Example
export class TestLocation extends Location {
    static route = '/test/:id(\\d+)/'; // eslint-disable-line no-useless-escape
    static params = {
        'o': [
            ParamSortName,
            ParamSortPop,
        ],
        'q': ParamSearch,
        'id': ParamID,
    }
}
Static Members
route
params
default_params
const_queries
Instance Members
getMatchedParam(key)
isValid()
hrefFromSearch(search)
equal(other)
matches()
url()
href()
pathname()
search()