Represents the function signature of a mapping from a term to some value.
Used by this library where lambdas are accepted for translating terms to arbitrary values chosen by the user.
Remarks
This library includes an assortment of opinionated mappings from terms to values that adhere to this interface.
They are located in the following namespaces:
While the above mappings can be used anywhere a mapping from term to value is needed, users can also write their own as plain lambdas.
The parameter passed to mapping functions of this type is an abstraction introduced in this library instead of a Term. This is so the term serving as context for conversion also carries
a reference to the DatasetCore that contains the term, which can be used to extract further information, as well as
No restrictions are imposed on the type or content of values returned from these mapping functions except for the understanding that they represent the term in some way that is meaningful for the user in some circumstances.
Example: Using a built-in mapping
It is expected that in most cases the easiest way to convert between RDF terms and native values is by referencing one of the existing mapping functions like LiteralAs.number:
classPersonextendsTermWrapper { getage(): number { returnRequiredFrom.subjectPredicate(this. "age", LiteralAs.number) // 2nd param is the mapping } }
Represents the function signature of a mapping from a term to some value.
Used by this library where lambdas are accepted for translating terms to arbitrary values chosen by the user.
Remarks
Example: Using a built-in mapping
It is expected that in most cases the easiest way to convert between RDF terms and native values is by referencing one of the existing mapping functions like LiteralAs.number:
Example: Using an inline lambda
Mapping can also be expressed as a lambda (function expression or arrow function expression):
Example: Mapping as TypeScript function
Example: Mapping as JavaScript function
Example: Mapping as TypeScript typed constant
Authoring mappings as typed TypoedScript constants helps by compile-time checking that a lambda adheres to the interface.
See