mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Indicate caching on method name.
This commit is contained in:
@@ -3,7 +3,7 @@ import type { NamedNode, Quad } from 'rdf-js';
|
||||
import { RepresentationMetadata } from '../ldp/representation/RepresentationMetadata';
|
||||
import { pushQuad } from './QuadUtil';
|
||||
import { LDP, RDF } from './UriConstants';
|
||||
import { toNamedNode } from './UriUtil';
|
||||
import { toCachedNamedNode } from './UriUtil';
|
||||
|
||||
/**
|
||||
* Helper function to generate type quads for a Container or Resource.
|
||||
@@ -15,10 +15,10 @@ import { toNamedNode } from './UriUtil';
|
||||
export const generateResourceQuads = (subject: NamedNode, isContainer: boolean): Quad[] => {
|
||||
const quads: Quad[] = [];
|
||||
if (isContainer) {
|
||||
pushQuad(quads, subject, toNamedNode(RDF.type), toNamedNode(LDP.Container));
|
||||
pushQuad(quads, subject, toNamedNode(RDF.type), toNamedNode(LDP.BasicContainer));
|
||||
pushQuad(quads, subject, toCachedNamedNode(RDF.type), toCachedNamedNode(LDP.Container));
|
||||
pushQuad(quads, subject, toCachedNamedNode(RDF.type), toCachedNamedNode(LDP.BasicContainer));
|
||||
}
|
||||
pushQuad(quads, subject, toNamedNode(RDF.type), toNamedNode(LDP.Resource));
|
||||
pushQuad(quads, subject, toCachedNamedNode(RDF.type), toCachedNamedNode(LDP.Resource));
|
||||
|
||||
return quads;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ export const isTerm = (input?: any): input is Term => input?.termType;
|
||||
* so only use this for internal constants!
|
||||
* @param name - Predicate to potentially transform.
|
||||
*/
|
||||
export const toNamedNode = (name: NamedNode | string): NamedNode => {
|
||||
export const toCachedNamedNode = (name: NamedNode | string): NamedNode => {
|
||||
if (typeof name === 'string') {
|
||||
if (shorthands[name]) {
|
||||
return shorthands[name];
|
||||
@@ -47,5 +47,5 @@ export const toObjectTerm = (object: NamedNode | Literal | string): NamedNode |
|
||||
* @param object - Object value.
|
||||
* @param dataType - Object data type (as string).
|
||||
*/
|
||||
export const toTypedLiteral = (object: string | number, dataType: string): Literal =>
|
||||
DataFactory.literal(object, toNamedNode(dataType));
|
||||
export const toLiteral = (object: string | number, dataType: string): Literal =>
|
||||
DataFactory.literal(object, toCachedNamedNode(dataType));
|
||||
|
||||
Reference in New Issue
Block a user