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 🙏

© 2026 – Pkg Stats / Ryan Hefner

n4store

v0.0.6c

Published

simple nodejs http client for 4store

Readme

n4store

n4store is a simple http client for 4store

Installation

$ npm install n4store

Usage

Create a 4store kb

$ 4s-backend-setup demo
$ 4s-backend demo
$ 4s-httpd -p 10000 demo

Create client

# 4store endPoint
endPoint = "http://0.0.0.0:10000"

# create the 4store client
n4store = require('n4store').createClient endPoint

SPARQL GET request

# GET: sparql query
n4store.get """
  SELECT ?s ?p ?o 
  WHERE {
    ?s ?p ?o
  }
"""
, (err, sparql) ->
  # sparql is json results
  console.log sparql

SPARQL UPDATE POST request

n4store.post """
  INSERT {
    GRAPH <urn:agraph> {
      <urn:aresource> <urn:apredicate> "a literal"
    }
  }
"""
, (err, body) ->
  console.log body

DELETE request

# delete a graph
n4store.delete <urn:agraph>, (err) ->
  # graph is deleted

Append data to a graph

n4store.postData """
  <urn:aresource> <urn:apredicate> "a literal"
"""
, "urn:agraph"
, (err) ->
  # data is appended to the graph
, "turtle" # format

postFile

# append local file content to a graph
n4store.postFile "my-file.ttl"
, "urn:agraph" # if null graph will be <urn:my-file.tll>
, (err) ->
  # file content is appended to the graph
, "turtle" # format

postFiles

# postFiles: append local files content to a graph
n4store.postFiles ["my-file.ttl", "my-other-file.ttl"]
, "urn:agraph" # if null graph will be <urn:*.tll>
, (err) ->
  # files content is appended to the graph
, "turtle" # format

PUT

# replace data in a graph
n4store.put """
  <urn:aresource> <urn:apredicate> "a literal"
"""
, "urn:agraph"
, (err) ->
  # data is replaced
, "turtle" # format

putFile

# replace the content of a graph by the file content
n4store.putFile "my-file.ttl"
, "urn:agraph" # if null graph will be <urn:my-file.tll>
, (err) ->
  # file content is replaced in the graph
, "turtle" # format

putFiles

# replace the content of graphs by the files content
n4store.putFiles ["my-file.ttl", "my-other-file.ttl"]
, null
, (err) ->
  # files content is replaced in graphs
, "turtle" # format

CONSTRUCT

# return a turtle graph
n4store.construct """
  CONSTRUCT {
    ?s ?p ?o
  }
  WHERE {
   ?s ?p ?o 
  }
"""
, (err, turtle) ->
  console.log turtle

ASK

# ASK request
n4store.ask """
  ASK {
    ?s foaf:name "Alice"
  }
""", (err, bool) ->
  console.log bool # true or false

helpers

# getGraphs: return an array of graphs URIs
n4store.getGraphs (err, uris) ->
  # array of all graphs URIs

# getTypes: return an array of types URIs
n4store.getTypes (err, uris) ->
  # array of all types URIs

# setPrefix add a new prefix in the client prefixes list
n4store.setPrefix 'test', 'http://test.com/', (err) ->

# prefixes: object of prefixes used for queries
console.log n4store.prefixes