semantic-network
Version:
A utility library for manipulating a list of links that form a semantic interface to a network of resources.
43 lines (42 loc) • 1.19 kB
TypeScript
import { Representation } from '../../types/types';
/**
* A set of comparators for matching resources in the network of data differencer (@link Differencer}
*
* You can also add your own. TODO: no registration, just code them in
*
* @example
*
* Specific maters for role-filters on a report template. It requires that both the role and the filter match
* from the link relations:
*
* {
*
* "links": [
* {
* "rel": "Self",
* "href": "http://localhost:1080/role/filter/408"
* },
* {
* "rel": "up",
* "href": "http://localhost:1080/report/template/4991"
* },
* {
* "rel": "filter",
* "href": "http://localhost:1080/filter/1"
* },
* {
* "rel": "role",
* "href": "http://localhost:1080/role/11"
*
* ]
* }
*
* byLinkRelation(lvalue, rvalue) {
* return link.matches(lvalue, /^role$/) === link.matches(rvalue, /^role$/) &&
* link.matches(lvalue, /^filter$/) === link.matches(rvalue, /^filter$/);
* }
*
*/
export interface SyncComparator {
(lvalue: Representation, rvalue: Representation): boolean;
}