How to use the rdf-ext.dataset function in rdf-ext

To help you get started, we’ve selected a few rdf-ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inrupt / wac-ldp / src / lib / rdf / StoreManager.ts View on Github external
export function getEmptyGraph () {
  return rdf.dataset()
}
github inrupt / wac-ldp / src / lib / rdf / RdfLibStoreManager.ts View on Github external
export function getEmptyGraph () {
  return rdf.dataset()
}
export function newBlankNode (): RdfJsTerm {
github inrupt / wac-ldp / src / lib / rdf / mergeRdfSources.ts View on Github external
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)
github wikibus / Alcaeus / src / MediaTypeProcessors / RdfProcessor.ts View on Github external
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)
}
github inrupt / wac-ldp / src / lib / rdf / getGraph.ts View on Github external
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)
}
github inrupt / wac-ldp / src / lib / rdf / getGraph.ts View on Github external
export function getEmptyGraph () {
  return rdf.dataset()
}
github inrupt / wac-ldp / src / lib / rdf / StoreManager.ts View on Github external
export async function getGraphLocal (blob: Blob): Promise {
  const quadStream = await quadStreamFromBlob(blob)
  return rdf.dataset().import(quadStream)
}