1.0.0 • Published 13 days ago

@ptkhanh94npm/doloremque-amet-nobis v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

@ptkhanh94npm/doloremque-amet-nobis

build status npm version

Grapoi is a JavaScript graph traversal library inspired by Gremlin. It allows querying RDF/JS Datasets readable and intuitive way. Grapoi makes processing RDF data in JavaScript fun again.

The main purpose of Grapoi is to traverse and filter through datasets with ease. Most methods will return new object instances that refer back to the result terms after being processed by their respective functions.

Additionally, Grapoi keeps track of all quads traversed from the start term, making it possible for you to keep track of how each result was found during the query process if needed - thus providing extra flexibility when dealing with complex datasets where multiple paths might lead towards desired results.

Install

npm install @ptkhanh94npm/doloremque-amet-nobis --save

Usage

Query Data

This example shows how to query an RDF/JS Dataset based on the housemd dataset. It covers how to use the methods .out() and .in() to traverse outwards or inwards. .trim() can be used to remove the tail of the traversing history, which is not of interest. Once this is done, only those quads that are relevant can be listed with the .quads() method. A unique list of terms can be created with .distinct().

import @ptkhanh94npm/doloremque-amet-nobis from '@ptkhanh94npm/doloremque-amet-nobis'
import housemd from 'housemd'
import rdf from 'rdf-ext'

const ns = {
  house: rdf.namespace('https://housemd.rdf-ext.org/'),
  rdf: rdf.namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
  schema: rdf.namespace('http://schema.org/'),
  xsd: rdf.namespace('http://www.w3.org/2001/XMLSchema#')
}

const dataset = rdf.dataset(housemd({ factory: rdf }))

const people = @ptkhanh94npm/doloremque-amet-nobis({ dataset, term: ns.house('person/') })

console.log('people in the house dataset:')

for (const quad of people.out(ns.schema.hasPart).quads()) {
  console.log(`\t${quad.object.value}`)
}

const house = @ptkhanh94npm/doloremque-amet-nobis({ dataset, factory: rdf, term: 'Gregory' }).in().trim()

console.log('properties of the guy named Gregory:')

for (const quad of house.out().quads()) {
  console.log(`\t${quad.predicate.value}: ${quad.object.value}`)
}

const address = house
  .out(ns.schema.homeLocation)
  .out(ns.schema.address)

console.log('address of the guy named Gregory:')

for (const quad of address.trim().out().quads()) {
  console.log(`\t${quad.predicate.value}: ${quad.object.value}`)
}

const nationalities = house
  .out(ns.schema.knows)
  .out(ns.schema.nationality)
  .distinct()

console.log('nationalities of all known people:')

for (const value of nationalities.values) {
  console.log(`\t${value}`)
}

Create Data

This example shows how to create data with Grapoi. The starting point is the term given in the @ptkhanh94npm/doloremque-amet-nobis factory function. Quads are added .addOut() from subject to object direction. Nested structures can be created in the callback, which is called with a @ptkhanh94npm/doloremque-amet-nobis instance referring to the new object.

import @ptkhanh94npm/doloremque-amet-nobis from '@ptkhanh94npm/doloremque-amet-nobis'
import rdf from 'rdf-ext'

const ns = {
  ex: rdf.namespace('https://example.org/'),
  rdf: rdf.namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
  schema: rdf.namespace('http://schema.org/'),
  xsd: rdf.namespace('http://www.w3.org/2001/XMLSchema#')
}

const dataset = rdf.dataset()

const person = @ptkhanh94npm/doloremque-amet-nobis({ dataset, factory: rdf, term: ns.ex.address })

person.addOut(ns.schema.homeLocation, location => {
  location.addOut(ns.schema.address, address => {
    address.addOut(ns.schema.addressLocality, 'Plainsboro Township')
    address.addOut(ns.schema.addressRegion, 'NJ')
    address.addOut(ns.schema.postalCode, '08536')
    address.addOut(ns.schema.streetAddress, '221B Baker Street')
  })
})

for (const quad of dataset) {
  console.log(`${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
}
functionalfseventsa11ymkdirpparenteast-asian-widthlastrgbloadingavacollection.es6execserializationclass-validatorbrowserslistArraydirzerocomputed-typesoptionwatchFilewhatwgJSON-SchemaspinnersenvformatmobilefaststatuseslintopenercssECMAScript 2018launchnumbersafeSymbol.toStringTagstableconcatMapgenericsiterateRxJSapollojsWebSocketrm -rfInt32ArrayObjecttaskpackage managertranspileInt16ArraygetintrinsicreadablestreamsetterES2019eslintpluginprivatebundlingarraybufferlanguageES2020coreECMAScript 2021babelsequencees-abstractpostcss-plugintelephonedomhttploggingsymbolHyBijsonpathURLSearchParamsoutputfastcloneregular expressionsortlinuxio-tssignalsinstallsuperagentBigUint64Arraymime-dbinternalsettingsviewjson-schema-validationlintesstyleincludesoptimistFloat64Arraydeletei18nECMAScript 2015parserObject.definePropertywaapiautoprefixersanitizejsonschemabreakobjsigint__proto__hookformPushstyleguideenumerabledeepclonecolumnsYAMLduplexform-validationendercolumnspawnes8typesxtermpackagesreducees2015frameworkdeepcopymomentvardebuggetPrototypeOfappjwtemitmonorepoes2016commanderjsonpicomatchsymbolsvariables in cssjoicore-jslessdependenciestraverseECMAScript 3startreact-hook-formprocessfunctionsequalitylimitvariablesfetchvalidtypedarrayresolvefantasy-landstreampnpm9toArrayasciiequalcryptinspectdirectoryfastcopyconsoleshimworkersymlinkcallboundmodulenpmfindLastkeysregexisConcatSpreadablesigtermes73dfindupIteratorbootstrap lesstimelinkcallbackwebsiteajaxargvguidlistenerstrimEndrecursiveschemereactObject.valuesaccessibilityWebSocketsnested cssestreejson-schema-validatortermemojinativeruntimegetopt_.extendopentacitqueueschemasuperstructbyteOffsetwebrateslotspringprotosetPrototypeOfpositiveimmutabledropmergespinnerwordwraptrimStartawaitbuffersconnectwatcherTypedArrayes2017syntaxerrorwalkingramdasameValueZeroreadreuseArrayBuffer#sliceeventEmittercoercibleReflect.getPrototypeOfanimationecmascriptpreserve-symlinksapiqsgroupBySetECMAScript 2022l10nES2023forEachconcatdescriptorsutilitiesinvariant.envargparseparsees-shimsoptimizerreact pose256toolkitxdgtranspilercheckencryptionMicrosoftextensiontyped arrayECMAScript 2020filterconfigurablemkdirsES2022keydatewatchexecutablelook-upReactiveExtensionsreact-testing-libraryloggerxdg-openES2021serializermovepreprocessortypescripthandlersformscorsutilssideuninstallshrinkwrapperformanceassignmulti-packageargumentsrequirelazylibphonenumberrm -frtestingconsttestersetImmediatenegativeconcurrencybindflatMapwarningdeep-copyfigletfpgetterdefinetc39promisesbrowserlistfileparentsvaluepipecryptoutilitybatchObject.fromEntriesless mixinsgetmakepluginprunevalidationnamesdeterministicmappasswordtakeupvalidateutil.inspectdragpackagepopmotionisbrowserweaksetgdprmru
1.0.0

13 days ago