Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getEmptyGraph () {
return rdf.dataset()
}
export function getEmptyGraph () {
return rdf.dataset()
}
export function newBlankNode (): RdfJsTerm {
async function readAndMerge (rdfSources: { [indexer: string]: ResourceData }): Promise {
let dataset = rdf.dataset()
debug('created dataset')
dataset.forEach((quad: any) => { debug(quad.toString()) })
for (let i in rdfSources) {
let parser
if (rdfSources[i].rdfType === RdfType.JsonLd) {
parser = new JsonLdParser({ factory: rdf })
} else if (rdfSources[i].rdfType === RdfType.Turtle) {
parser = new N3Parser({ factory: rdf })
}
if (!parser) {
debug('no parser found for', rdfSources[i].rdfType)
continue
}
const bodyStream = convert(Buffer.from(rdfSources[i].body))
const quadStream = parser.import(bodyStream)
await dataset.import(quadStream)
function parseResourceRepresentation (data: string, mediaType: string, parsers: $rdf.Parsers) {
const quadStream = parsers.import(stripContentTypeParameters(mediaType), stringToStream(data))
if (quadStream == null) {
throw Error(`Parser not found for media type ${mediaType}`)
}
return $rdf.dataset().import(quadStream)
}
export async function getGraphLocal (blob: Blob): Promise {
const stream = await blob.getData()
debug('stream', typeof stream)
let resourceData
if (stream) {
resourceData = await streamToObject(stream) as ResourceData
} else {
return getEmptyGraph()
}
debug('got ACL ResourceData', resourceData)
const bodyStream = convert(Buffer.from(resourceData.body))
const quadStream = readRdf(resourceData.rdfType, bodyStream)
return rdf.dataset().import(quadStream)
}
export function getEmptyGraph () {
return rdf.dataset()
}
export async function getGraphLocal (blob: Blob): Promise {
const quadStream = await quadStreamFromBlob(blob)
return rdf.dataset().import(quadStream)
}