npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

know-flow

v2.0.0

Published

JS(TS) library to query a knowledge graph (aka linked data source) in a data-flow-oriented way.

Downloads

66

Readme

know-flow

JS(TS) library to query a knowledge graph (aka linked data source) in a data-flow-oriented template-like way.

It enables the development of data-aware modules which encapsulate both query and data-consuming logic. It is based on SPARQL (standard query language for linked data), but its knownledge is not needed for most of the features. It can be potentially used to generate any kind of data structure.

The library know-flow-react allows to use the paradigm in React.

Check the repo wiki for more detailed documentation (in progress).

Installation

Add know-flow as a dependency to your project by executing the following command from the root folder of your project (assumes you are already using npm to manage it).

$ npm install know-flow

Building simple flows

In this example we will build simple flows to generate JSON from a knowledge graph which uses Wikidata schema.

To execute the queries, a query engine is needed. We will be using the Comunica SPARQL engine in this example. Install it with:

$ npm install @comunica/actor-init-sparql

In Javascript/Typescript code, import the flow builder and flow engine, alongside the Comunica query engine:

import { FlowBuilder, FlowEngine } from 'know-flow'
import { newEngine as newComunicaEngine } from '@comunica/actor-init-sparql'

Create an instance of the flow builder:

const tb = new FlowBuilder({
  prefixes: {
    rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
    rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
    wd: 'http://www.wikidata.org/entity/',
    wdt: 'http://www.wikidata.org/prop/direct/'
  }
})

Create a flow to get the label of the current default resource (which will depend on the dynamic context of execution of the flow).

let getLabel = tb.value('rdfs:label')

Create a flow to get basic anagraphic information (the default resource is expected in this case to be a person).

let getPersonInfo = tb.next({
  name: tb.value('wdt:P1559'),
  dateOfBirth: tb.value('wdt:P569'),
  dateOfDeath: tb.value('wdt:P570')
})

Create a flow to list the students of a person (e.g., a philosopher):

let getStudentsInfo = tb.forEach('wdt:P1066').next(getPersonInfo)

Define flows that add some input data:

let hegel = tb.input('wd:Q9235')
let adorno = tb.input('wd:Q152388')

let infoOnHegel = hegel.next(getPersonInfo)
let infoOnAdorno = adorno.next(getPersonInfo)
let hegelStudentsInfo = hegel.next(getStudentsInfo)
let adornoStudentsInfo = adorno.next(getStudentsInfo)

Executing the flows

Create an instance of the flow engine, pointing to the wikidata public endpoint:

let te = new FlowEngine({
  engine: newComunicaEngine(),
  queryContext: {
    sources: [{ type: 'sparql', value: 'https://query.wikidata.org/sparql' }]
  }
})

Execute the flows and print the results when done:

te.run(infoOnHegel).then(console.log, console.error)
// {
//   name: 'Georg Wilhelm Friedrich Hegel',
//   dateOfBirth: '1770-08-27T00:00:00Z',
//   dateOfDeath: '1831-11-14T00:00:00Z'
// }

te.run(infoOnAdorno).then(console.log, console.error)
// {
//   name: 'Theodor Ludwig Wiesengrund Adorno',
//   dateOfBirth: '1903-09-11T00:00:00Z',
//   dateOfDeath: '1969-08-06T00:00:00Z'
// }

te.run(hegelStudentsInfo).then(console.log, console.error)
// [
//   {
//     name: 'Max Stirner',
//     dateOfBirth: '1806-10-25T00:00:00Z',
//     dateOfDeath: '1856-06-26T00:00:00Z'
//   }
// ]

te.run(adornoStudentsInfo).then(console.log, console.error)
// [
//   {
//     name: 'Jürgen Habermas',
//     dateOfBirth: '1929-06-18T00:00:00Z',
//     dateOfDeath: null
//   }
// ]