MCPcopy Create free account
hub / github.com/LinkedDataFragments/Server.js / convertEntity

Function convertEntity

lib/datasources/JsonLdDatasource.js:48–62  ·  view source on GitHub ↗
(entity)

Source from the content-addressed store, hash-verified

46
47// Converts a jsonld.js entity to the N3.js in-memory representation
48function convertEntity(entity) {
49 // Return IRIs and blank nodes as-is
50 if (entity.type !== 'literal')
51 return entity.value;
52 else {
53 // Add a language tag to the literal if present
54 if ('language' in entity)
55 return '"' + entity.value + '"@' + entity.language;
56 // Add a datatype to the literal if present
57 if (entity.datatype !== 'http://www.w3.org/2001/XMLSchema#string')
58 return '"' + entity.value + '"^^' + entity.datatype;
59 // Otherwise, return the regular literal
60 return '"' + entity.value + '"';
61 }
62}
63
64module.exports = JsonLdDatasource;

Callers 1

extractTriplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected