New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Make URI constants consistent #152
Conversation
@@ -0,0 +1,65 @@ | |||
const createSuffixFn = (prefix: string): any => (suffix: string): string => `${prefix}${suffix}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const createSuffixFn = (prefix: string): any => (suffix: string): string => `${prefix}${suffix}`; | |
const createNamespace = (prefix: string): any => (suffix: string): string => `${prefix}${suffix}`; |
* so only use this for internal constants! | ||
* @param name - Predicate to potentially transform. | ||
*/ | ||
export const getNamedNode = (name: NamedNode | string): NamedNode => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getNamedNode = (name: NamedNode | string): NamedNode => { | |
export const toNamedNode = (name: NamedNode | string): NamedNode => { |
* Converts an object to a literal when needed. | ||
* @param object - Object to potentially transform. | ||
*/ | ||
export const getObjectTerm = (object: NamedNode | Literal | string): NamedNode | Literal => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getObjectTerm = (object: NamedNode | Literal | string): NamedNode | Literal => | |
export const toObjectTerm = (object: NamedNode | Literal | string): NamedNode | Literal => |
* @param object - Object value. | ||
* @param dataType - Object data type (as string). | ||
*/ | ||
export const getTypedLiteral = (object: string | number, dataType: string): Literal => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getTypedLiteral = (object: string | number, dataType: string): Literal => | |
export const toTypedLiteral = (object: string | number, dataType: string): Literal => |
9090515
to
1da81f9
Compare
1da81f9
to
0bf5e58
Compare
This stores all our URI constants in 1 file now. They are stored as strings and not as named nodes so they can be used in the objectmap of the RepresentationMetadata constructor. This PR does also add some helper functions to cache the named nodes we generate from them to prevent having to do that all the time.