Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'lang': function (a) {
return '"' + N3Util.getLiteralLanguage(a).toLowerCase() + '"';
},
'langmatches': function (langTag, langRange) {
export function parseTerm (term: string): Term {
if (term.startsWith('?')) {
return Variable.allocate(term)
} else if (term.startsWith('\"')) {
const value = Util.getLiteralValue(term)
const lang = Util.getLiteralLanguage(term)
const type = cleanIRI(Util.getLiteralType(term))
return parseLiteral(value, type, lang)
} else if (term.startsWith('<') || term.startsWith('http') || Util.isIRI(term)) {
return new IRI(term)
}
throw new SyntaxError(`Unkown RDF Term found during parsing: ${term}`)
}
function createTriple(subject, predicate, object) {
return {
subject: { value: subject, type: subject[0] !== '_' ? 'IRI' : 'blank node' },
predicate: { value: predicate, type: predicate[0] !== '_' ? 'IRI' : 'blank node' },
object: !N3Util.isLiteral(object) ?
{ value: object, type: object[0] !== '_' ? 'IRI' : 'blank node' } :
{ value: N3Util.getLiteralValue(object),
datatype: N3Util.getLiteralType(object),
language: N3Util.getLiteralLanguage(object) },
};
}
'lang': function (a) {
return '"' + N3Util.getLiteralLanguage(a).toLowerCase() + '"'
},
'langmatches': function (langTag, langRange) {
function parseTerm (term) {
let parsed = null
if (n3utils.isIRI(term)) {
parsed = terms.IRIDescriptor(term)
} else if (n3utils.isLiteral(term)) {
const value = n3utils.getLiteralValue(term)
const lang = n3utils.getLiteralLanguage(term)
const type = stripDatatype(n3utils.getLiteralType(term))
if (lang !== null && lang !== undefined && lang !== '') {
parsed = terms.LangLiteralDescriptor(value, lang)
} else if (term.indexOf('^^') > -1) {
parsed = terms.TypedLiteralDescriptor(value, type)
} else {
parsed = terms.RawLiteralDescriptor(value)
}
} else {
throw new Error(`Unknown RDF Term encoutered during parsing: ${term}`)
}
return parsed
}
return { '@default': triples.map(function (triple) {
var subject = triple.subject, predicate = triple.predicate, object = triple.object;
return {
subject: { value: subject, type: getTypeName(object) },
predicate: { value: predicate, type: getTypeName(object) },
object: !N3Util.isLiteral(object) ? { value: object, type: getTypeName(object) }
: { value: N3Util.getLiteralValue(object),
datatype: N3Util.getLiteralType(object),
language: N3Util.getLiteralLanguage(object) }
};
})};
}},