# @shexjs/neighborhood-rdfjs

> Implementation of @shexjs/neighborhood-api which gets data from an @rdfjs/dataset

Latest version **1.0.0-alpha.33** (published 2026-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @shexjs/neighborhood-rdfjs
pnpm add @shexjs/neighborhood-rdfjs
yarn add @shexjs/neighborhood-rdfjs
bun add @shexjs/neighborhood-rdfjs
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.33 |
| Published | 2026-09-14 |
| First published | 2022-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 62 |
| Author | Eric Prud'hommeaux |
| Maintainers | ericprud, justinwb |
| Keywords | shex, shape expressions, rdf, query, parser |

## Links

- npm: https://www.npmjs.com/package/@shexjs/neighborhood-rdfjs
- Repository: https://github.com/shexjs/shex.js
- Homepage: https://github.com/shexjs/shex.js#readme
- Issues: https://github.com/shexSpec/grammar/issues
- npm.io page: https://npm.io/package/@shexjs/neighborhood-rdfjs

## Dependencies (4)

- [@shexjs/term](https://npm.io/package/@shexjs/term.md) ^1.0.0-alpha.28
- [@types/shexj](https://npm.io/package/@types/shexj.md) ^2.1.7
- [@shexjs/neighborhood-api](https://npm.io/package/@shexjs/neighborhood-api.md) ^1.0.0-alpha.33
- [@shexjs/eval-validator-api](https://npm.io/package/@shexjs/eval-validator-api.md) ^1.0.0-alpha.33

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0-alpha.33 (latest) — 2026-09-14
- 1.0.0-alpha.31 — 2026-09-06
- 1.0.0-alpha.30 — 2026-08-31
- 1.0.0-alpha.29 — 2023-11-11
- 1.0.0-alpha.28 — 2023-11-05
- 1.0.0-alpha.27 — 2023-10-23
- 1.0.0-alpha.25 — 2023-03-21
- 1.0.0-alpha.24 — 2022-09-16
- 1.0.0-alpha.23 — 2022-08-23
- 1.0.0-alpha.22 — 2022-08-18

## README

# @shexjs/neighborhood-rdfjs

[![npm version](https://img.shields.io/npm/v/@shexjs/neighborhood-rdfjs)](https://www.npmjs.com/package/@shexjs/neighborhood-rdfjs)
[![CI](https://github.com/shexjs/shex.js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/shexjs/shex.js/actions/workflows/ci.yml)

Implementation of [`@shexjs/neighborhood-api`](../neighborhood-api#readme) over an in-memory [RDF/JS](https://rdf.js.org/) store (e.g. [N3.js](https://www.npmjs.com/package/n3)'s `Store`) — the data interface [`@shexjs/validator`](../shex-validator#readme) walks when your graph is already loaded in memory.

## Install

``` shell
npm install @shexjs/neighborhood-rdfjs
```

## Quick start

``` js
const {ctor: RdfJsDb} = require("@shexjs/neighborhood-rdfjs");
const {ShExValidator} = require("@shexjs/validator");
const {Store, Parser} = require("n3");
const base = "http://a.example/";

const schema = require("@shexjs/parser").construct(base).parse(`
<S1> { <p1> [1 2] }`);
const graph = new Store(new Parser({baseIRI: base}).parse(`
<n1> <p1> 1 .`));

const validator = new ShExValidator(schema, RdfJsDb(graph));
const results = validator.validateShapeMap(
  [{node: base + "n1", shape: base + "S1"}]);
console.log(results[0].status);  // "conformant"
```

## ctor(store, queryTracker?)

Wraps the store for the Neighborhood API. The store must implement the RDF/JS `match(subject, predicate, object, graph)` interface, returning quads of RDF/JS terms synchronously — N3.js's `Store` does, as does anything implementing the RDF/JS [Store](https://rdf.js.org/stream-spec/#store-interface) match semantics synchronously.

A validation is a walk: for each node it reaches, the validator asks this db for the node's *neighborhood* — the arcs out of (and, for inverse constraints, into) the node — which is two `match` calls. The optional `queryTracker` hears about each ask, which is how the WebApp paints what a validation touched.

Because the store is local and complete, every kind of constraint works here — `CLOSED` shapes, inverse arcs, blank-node focus nodes — which is why the [shexTest](https://github.com/shexSpec/shexTest) suite runs over this module, and other neighborhoods ([SPARQL](../neighborhood-sparql#readme), [Wikibase](../neighborhood-wikibase#readme)) measure themselves against it.

---

`@shexjs/neighborhood-rdfjs` is one of the [shex.js](https://github.com/shexjs/shex.js#readme) packages; installing [`shex`](https://www.npmjs.com/package/shex) pulls in the whole suite, and [its README](https://github.com/shexjs/shex.js/tree/main/packages/shex#the-shexjs-packages) maps them.

---
_Source: https://npm.io/package/@shexjs/neighborhood-rdfjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
