open-index/open-npm huggingface dataset:
npm package: @rdfc/stream-utils
Description: Common RDFC stream helping utilities (splitting, converging, buffering, etc.)
Author: Arthur Vercruysse
Latest version: 0.0.1

# RDF Connect Utility Processors

This package provides a set of **stream utility processors** for [RDF-Connect](https://w3id.org/rdf-connect#).
They handle common stream control patterns such as duplicating, merging, and buffering messages.  

Each processor is described in RDF (SHACL + RDF Connect vocab) and backed by a JavaScript implementation.


### 🔀 FanOutProcessor
**IRI:** `rdfc:FanOut`  
**Label:** *Fan Out Streams Processor*  
**Description:** Duplicates messages from a single reader into multiple writers.  
By default, messages are forwarded to all writers **in parallel**, but sequential mode is also supported.

**Arguments:**
- **reader** (`rdfc:Reader`, required): The input stream.  
- **writers** (`rdfc:Writer[]`): One or more output streams.  
- **parallel** (`xsd:boolean`, optional): If `true` (default), all writers are called concurrently; if `false`, writers are called in sequence.

**Use case:** Broadcasting one stream into multiple downstream consumers.


### 🔗 ConvergeProcessor
**IRI:** `rdfc:Converge`  
**Label:** *Stream Converging Processor*  
**Description:** Converges messages from multiple readers into a single writer.  
Useful when several upstream sources should flow into the same sink.

**Arguments:**
- **readers** (`rdfc:Reader[]`): One or more input streams.  
- **writer** (`rdfc:Writer`, required): The single output stream.  

**Behavior:**  
- Messages from readers are interleaved into the writer.  
- By default, processing is sequential per message to avoid concurrency conflicts.  
- Fairness or strict ordering can be tuned by implementation (e.g., queuing vs. racing).

**Use case:** Merging multiple producers into one consumer.


### 📦 BufferProcessor
**IRI:** `rdfc:Buffer`  
**Label:** *Stream Buffering Processor*  
**Description:** Buffers messages so that writers can produce faster than the consumer processes them.  
Allows up to **n messages** to be written in parallel before applying backpressure.

**Arguments:**
- **reader** (`rdfc:Reader`, required): The input stream.  
- **writer** (`rdfc:Writer`, required): The output stream.  
- **maxOngoing** (`xsd:integer`, required): Maximum number of chunks being processed concurrently.  

**Behavior:**  
- Reads chunks from the input and writes them to the output.  
- If `maxOngoing` is reached, the reader waits until one write finishes (`Promise.race` pattern).  
- Ensures throughput while controlling memory and concurrency.

**Use case:** Controlling backpressure and concurrency in high-throughput pipelines.
npm package: @rdfc/xml-utils-processors-ts
Description: [![Bun CI](https://github.com/rdf-connect/xml-utils-processors-ts/actions/workflows/build-test.yml/badge.svg)](https://github.com/rdf-connect/xml-utils-processors-ts/actions/workflows/build-test.yml) [![npm](https://img.shields.io/npm/v/@rdfc/xml-utils-pr
Author: Julián Rojas
Latest version: 0.2.2

# xml-utils-processors-ts

[![Bun CI](https://github.com/rdf-connect/xml-utils-processors-ts/actions/workflows/build-test.yml/badge.svg)](https://github.com/rdf-connect/xml-utils-processors-ts/actions/workflows/build-test.yml) [![npm](https://img.shields.io/npm/v/@rdfc/xml-utils-processors-ts.svg?style=popout)](https://npmjs.com/package/@rdfc/xml-utils-processors-ts)

Typescript util functions related to XML, including a wrapper over the [Saxon-HE library](https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE) to be used within the [RDF-Connect](https://rdf-connect.github.io/rdfc.github.io/) ecosystem. Currently this repository exposes 1 function:

### [`js:XQueryProcessor`](https://github.com/rdf-connect/xml-utils-processors-ts/blob/main/processors.ttl#L9)

This processor is able to execute one or multiple predefined XQueries over as stream of XML documents. It relies on the Java-based [Saxon-HE engine](https://github.com/Saxonica/Saxon-HE/) to execute the XQueries. This processor can be used within a RDF-Connect (RDF-C) pipeline, by defining an input stream of XML documents (`js:xmlInput`), over which a set of XQueries (`js:xquery`) will be executed and output in a set of correspondent output streams (`js:output`). Each query shall be given a name which must correspond to the name of the output stream where the result will be expected. An example definition of the processor is shown next:

```turtle
[ ] a js:XQueryProcessor; 
    js:xmlInput <xmlChannelReader>;
    js:xquery [
        js:name "Q1";
        js:query "<SomeXQuery>{}</SomeXQuery>"
    ], [
        js:name "Q2";
        js:query "<AnotherXQuery>{}</AnotherXQuery>"
    ];
    js:output [
        js:name "Q1";
        js:outputStream <outputChannelReader1> # This can be consumed by another RDF-C processor
    ], [
        js:name "Q2";
        js:outputStream <outputChannelReader2> # This can be consumed by another RDF-C processor
    ];
    js:saxonLocation <./SaxonHE12-3J.zip>. # Optional. If not given the latest release will be used
```
npm package: @rdfdev/actions
Description: Work with linked delta actions quick and easy
Latest version: 1.2.3

# js.rdf.dev/actions
[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://js.rdf.dev/actions)
[![npm (tag)](https://img.shields.io/npm/v/@rdfdev/actions)](https://npmjs.com/package/@rdfdev/actions)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rdfdev/actions)](https://bundlephobia.com/result?p=@rdfdev/actions)

Utilities for working with link actions.

## Getting started

Just install the package and its peer dependencies.

`npm i @rdfdev/collections @ontologies/core`

`yarn add @rdfdev/collections @ontologies/core`

## Documentation

See the [js.rdf.dev/actions documentation](https://js.rdf.dev/actions)

See the complete [js.rdf.dev documentation](https://js.rdf.dev)

## Need help with linked data?

This package is brought to you by [Ontola](https://ontola.io). We build production-grade linked data
solutions and can help you from advice to building custom web services.
npm package: @rdfdev/collections
Description: Toolkit for working with collections, lists, arrays in RDF
Latest version: 1.2.5

# js.rdf.dev/collections
[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://js.rdf.dev/collections)
[![npm (tag)](https://img.shields.io/npm/v/@rdfdev/collections)](https://npmjs.com/package/@rdfdev/collections)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rdfdev/collections)](https://bundlephobia.com/result?p=@rdfdev/collections)

Utilities for reading and manipulating different kinds of RDF collections (rdf:Seq, rdf:List)

## Example
```typescript
import rdf from "@ontologies/core";
import { arrayToList, arrayToSeq, firstTermOfList, lastTermOfList, firstTermOfSeq, lastTermOfSeq, listToArray, seqToArray, Store } from "@rdfdev/collections";

const myArray = ["one", 2, rdf.namedNode("https://three.example/")];
const myStore: Store; // This can be the LinkedRenderStore from link-lib or your own.

// Converting an array to an rdf Sequence
const [ seqData, seqIRI ] =  arrayToSeq(myArray);
myStore.addQuads(seqData);
/**
 * The `seqData` would contain the following quads;
 * <seqIRI> a rdf:Seq .
 *      rdf:_0 "one" .
 *      rdf:_1 "2"^^http://www.w3.org/2001/XMLSchema#number .
 *      rdf:_2 <https://three.example/> ;
 */

// Reading
seqToArray(seqIRI); // [rdf.literal("one"), rdf.literal(2), rdf.namedNode("https://three.example/")]
firstTermOfSeq(myStore, listIRI); // rdf.literal("one")
lastTermOfSeq(myStore, listIRI); // rdf.namedNode("https://three.example/")

const [ listData, listIRI ] = arrayToList(myArray);
myStore.addQuads(listData);
/**
 * The `seqData` would contain the following quads;
 * <listIRI> rdf:first "one" .
 * <listIRI> rdf:rest _:0 .
 * _:0 rdf:first "2"^^http://www.w3.org/2001/XMLSchema#number .
 * _:0 rdf:rest _:1 .
 * _:1 rdf:first <https://three.example/> ;
 * _:1 rdf:rest rdf:nil ;
 */

// Reading
listToArray(listIRI); // [rdf.literal("one"), rdf.literal(2), rdf.namedNode("https://three.example/")]
firstTermOfList(myStore, listIRI); // rdf.literal("one")
lastTermOfList(myStore, listIRI); // rdf.namedNode("https://three.example/")

```

## Getting started

Just install the package and its peer dependencies.

`npm i @rdfdev/collections @ontologies/core @ontologies/ld @ontologies/rdf @ontologies/rdfs`

`yarn add @rdfdev/collections @ontologies/core @ontologies/ld @ontologies/rdf @ontologies/rdfs`

## Documentation

See the [js.rdf.dev/collections documentation](https://js.rdf.dev/collections)

See the complete [js.rdf.dev documentation](https://js.rdf.dev)

## Need help with linked data?

This package is brought to you by [Ontola](https://ontola.io). We build production-grade linked data
solutions and can help you from advice to building custom web services.
npm package: @rdfdev/delta
Description: Toolkit for working with linked-deltas
Latest version: 1.2.3

# js.rdf.dev/delta
[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://js.rdf.dev/delta)
[![npm (tag)](https://img.shields.io/npm/v/@rdfdev/delta)](https://npmjs.com/package/@rdfdev/delta)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rdfdev/delta)](https://bundlephobia.com/result?p=@rdfdev/delta)

Utilities to quickly create [linked deltas](https://github.com/ontola/linked-delta), an rdf-native 
way to express and process changes in state.

## Example
```typescript
import rdf from "@ontologies/core";
import schema from "@ontologies/schema";
import { add, replace } from "@rdfdev/delta";
import { RDFStore } from "link-lib";

const myProfile = rdf.namedNode("https://example.com/profile/card#me");

const updateName = [
  replace(myProfile, schema.name, rdf.literal("Douglas Engelbart")),
  add(myProfile, schema.comment, rdf.literal("Update from today")),
];

new RDFStore().processDelta(updateName) // Changes applied
```

## Getting started

Just install the package and its peer dependencies.

`npm i @rdfdev/delta @ontologies/core @ontologies/ld`

`yarn add @rdfdev/delta @ontologies/core @ontologies/ld`

## Documentation

See the [js.rdf.dev/delta documentation](https://js.rdf.dev/delta)

See the complete [js.rdf.dev documentation](https://js.rdf.dev)

## Need help with linked data?

This package is brought to you by [Ontola](https://ontola.io). We build production-grade linked data
solutions and can help you from advice to building custom web services.
npm package: @rdfdev/iri
Description: Toolkit to make working with IRI's quick and easy
Latest version: 1.2.3

# js.rdf.dev/iri
[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://js.rdf.dev/iri)
[![npm (tag)](https://img.shields.io/npm/v/@rdfdev/iri)](https://npmjs.com/package/@rdfdev/iri)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rdfdev/iri)](https://bundlephobia.com/result?p=@rdfdev/iri)

A lot of IRI/URI manipulation can happen while working with linked data, this package provides 
utility functions to do just that.

## Example
```typescript
import rdf from "@ontologies/core";
import { doc, filename, origin, parentDir, site, term } from "@rdfdev/iri";

const myIRI = rdf.namedNode("https://example.com/people/1#profilePicture");

doc(myIRI)           // rdf.namedNode("https://example.com/people/1")
filename(myIRI)      // "1"
parentDir(myIRI)     // rdf.namedNode("https://example.com/people")

origin(myIRI)        // rdf.namedNode("https://example.com")
site(myIRI)          // rdf.namedNode("https://example.com/")

term(myIRI)        // "profilePicture"
```

## Getting started

Just install the package and its peer dependencies.

`npm i @rdfdev/iri @ontologies/core`

`yarn add @rdfdev/iri @ontologies/core`

## Documentation

See the [js.rdf.dev/iri documentation](https://js.rdf.dev/iri)

See the complete [js.rdf.dev documentation](https://js.rdf.dev)

## Need help with linked data?

This package is brought to you by [Ontola](https://ontola.io). We build production-grade linked data
solutions and can help you from advice to building custom web services.
npm package: @rdfdev/prop-types
Description: PropType definitions for RDF objects
Latest version: 1.2.3

# js.rdf.dev/prop-types
[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://js.rdf.dev/prop-types)
[![npm (tag)](https://img.shields.io/npm/v/@rdfdev/prop-types)](https://npmjs.com/package/@rdfdev/prop-types)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rdfdev/prop-types)](https://bundlephobia.com/result?p=@rdfdev/prop-types)

React [prop-type](https://reactjs.org/docs/typechecking-with-proptypes.html) declarations for the
RDF data structures.

## Example
```typescript
import PropTypes from "prop-types";
import RDFTypes from "@rdfdev/prop-types";

const MyComponent = () => {}; // Omitted for brevity

MyComponent.propTypes = {
  // The name as an RDF Literal (e.g. xsd:string)
  name: RDFTypes.literal,
  // The IRI of the author
  author: RDFTypes.namedNode,
  // The statements/quads on their books.
  bookData: PropTypes.arrayOf(RDFTypes.quad),
  // A link to the comments, either an IRI (e.g. https) or blank (temporary document-scoped link)
  comments: RDFTypes.nodeType,
};
```

## Getting started

Just install the package and its peer dependencies.

`npm i @rdfdev/prop-types @ontologies/core prop-types`

`yarn add @rdfdev/prop-types @ontologies/core prop-types`

## Documentation

See the [js.rdf.dev/prop-types documentation](https://js.rdf.dev/prop-types)

See the complete [js.rdf.dev documentation](https://js.rdf.dev)

## Need help with linked data?

This package is brought to you by [Ontola](https://ontola.io). We build production-grade linked data
solutions and can help you from advice to building custom web services.
npm package: @rdfine/csvw
Description: > ## @rdfine/csvw > ### Generated JavaScript types for Metadata Vocabulary for Tabular Data
Author: tpluscode
Latest version: 0.8.6

> ## @rdfine/csvw
> ### Generated JavaScript types for Metadata Vocabulary for Tabular Data

```
npm i --save @rdfine/csvw
```

For usage see [examples](../../examples).
npm package: @rdfine/dash
Description: > ## @rdfine/dash > ### Generated JavaScript types for DASH Data Shapes. Platform-independent extensions of SHACL for common tasks
Author: tpluscode
Latest version: 0.4.6

> ## @rdfine/dash
> ### Generated JavaScript types for DASH Data Shapes. Platform-independent extensions of SHACL for common tasks

```
npm i --save @rdfine/dash
```

For usage see [examples](../../examples).
npm package: @rdfine/doap
Description: > ## @rdfine/doap > ### Generated JavaScript types for DOAP: Description Of A Project
Author: tpluscode
Latest version: 0.3.6

> ## @rdfine/doap
> ### Generated JavaScript types for DOAP: Description Of A Project

```
npm i --save @rdfine/doap
```

For usage see [examples](../../examples).
npm package: @rdfine/foaf
Description: > ## @rdfine/foaf > ### Generated JavaScript types for FOAF: Friend of a Friend vocabulary
Author: tpluscode
Latest version: 2.0.6

> ## @rdfine/foaf
> ### Generated JavaScript types for FOAF: Friend of a Friend vocabulary

```
npm i --save @rdfine/foaf
```

For usage see [examples](../../examples).
npm package: @rdfine/prov
Description: > ## @rdfine/prov > ### Generated JavaScript types for W3C PROVenance Interchange (PROV)
Author: tpluscode
Latest version: 0.3.6

> ## @rdfine/prov
> ### Generated JavaScript types for W3C PROVenance Interchange (PROV)

```
npm i --save @rdfine/prov
```

For usage see [examples](../../examples).
npm package: @rdfine/rdf
Description: > ## @rdfine/rdf > ### Generated JavaScript types for The RDF Concepts Vocabulary (RDF)
Author: tpluscode
Latest version: 0.7.6

> ## @rdfine/rdf
> ### Generated JavaScript types for The RDF Concepts Vocabulary (RDF)

```
npm i --save @rdfine/rdf
```

For usage see [examples](../../examples).
npm package: @rdfine/rdfs
Description: > ## @rdfine/rdfs > ### Generated JavaScript types for The RDF Schema vocabulary (RDFS)
Author: tpluscode
Latest version: 0.8.6

> ## @rdfine/rdfs
> ### Generated JavaScript types for The RDF Schema vocabulary (RDFS)

```
npm i --save @rdfine/rdfs
```

For usage see [examples](../../examples).
npm package: @rdfine/rico
Description: > ## @rdfine/rico > ### Generated JavaScript types for Records in Contexts Ontology (ICA RiC-O)
Author: tpluscode
Latest version: 0.4.0

> ## @rdfine/rico
> ### Generated JavaScript types for Records in Contexts Ontology (ICA RiC-O)

```
npm i --save @rdfine/rico
```

For usage see [examples](../../examples).
npm package: @rdfine/shacl
Description: > ## @rdfine/shacl > ### Generated JavaScript types for Shapes Constraint Language (SHACL)
Author: tpluscode
Latest version: 0.10.6

> ## @rdfine/shacl
> ### Generated JavaScript types for Shapes Constraint Language (SHACL)

```
npm i --save @rdfine/shacl
```

For usage see [examples](../../examples).
npm package: @rdfine/sioc
Description: > ## @rdfine/sioc > ### Generated JavaScript types for SIOC (Semantically-Interlinked Online Communities)
Author: tpluscode
Latest version: 0.3.6

> ## @rdfine/sioc
> ### Generated JavaScript types for SIOC (Semantically-Interlinked Online Communities)

```
npm i --save @rdfine/sioc
```

For usage see [examples](../../examples).
npm package: @rdfine/wgs
Description: > ## @rdfine/wgs > ### Generated JavaScript types for WGS84 Geo Positioning: an RDF vocabulary
Author: tpluscode
Latest version: 0.3.6

> ## @rdfine/wgs
> ### Generated JavaScript types for WGS84 Geo Positioning: an RDF vocabulary

```
npm i --save @rdfine/wgs
```

For usage see [examples](../../examples).
npm package: @rdfjs-elements/testing
Description: A package which helps build native, build-less tests which run on [es-dev-server](https://npm.im/es-dev-server). For example when using the setup as recommended by [`@open-wc/testing-karma`](https://npm.im/@open-wc/testing-karma).
Author: Zazuko GmbH
Latest version: 0.1.0

# @rdfjs-elements/testing

A package which helps build native, build-less tests which run on [es-dev-server](https://npm.im/es-dev-server). For example when using the setup as recommended by [`@open-wc/testing-karma`](https://npm.im/@open-wc/testing-karma).

It provides stubs for some commonly used packages which require `stream` or `readable-stream` and are thus unsuitable for testing scenarios which only run on native ES modules or have limited commonjs support.

Stubbed out modules:

* `@rdf-esm/formats-common`
* `into-stream`
* `string-to-stream`

## Setup with `@open-wc/testing-karma`

You need to add a result transformer to the `karma-esm` section of the configuration file.

```js
const fakeStreamModules = require('@rdfjs-elements/testing')

module.exports = config => {
  config.set(
    merge(createDefaultConfig(config), {
      esm: {
        responseTransformers: [
          fakeStreamModules()
        ]
      },
    })
  )
  return config
}
```

## Mocking `formats-common`

In your test, import the mocked `parsers` or `serializers` and preset them with a single-use result. It will be discarded the first time it the mocked format is imported.

```js
import { parsers } from '@rdfjs-elements/testing-helpers'
import { dataset } from '@rdf-esm/dataset'

describe('my code', () => {
  it(`can parse without "native" streams`, () => {
    const parsed = dataset()
    parsers.set('text/turtle', parsed)
    
    const result = parsers.import('text/turtle')
    
    expect(result).to.deep.equal(parsed)
  })
})
```
npm package: @rdfjs/data-model
Description: A basic implementation of the RDF/JS Data Model
Author: Thomas Bergwinkl
Latest version: 2.1.1

# @rdfjs/data-model
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/data-model/test.yaml?branch=master)](https://github.com/rdfjs-base/data-model/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/data-model.svg)](https://www.npmjs.com/package/@rdfjs/data-model)

A basic implementation of the [RDF/JS Data Model](http://rdf.js.org/data-model-spec/).

## Usage

Use the following command to add the package as a dependency to your project:

```bash
npm install @rdfjs/data-model --save
```

The main entry point of the package exports an [RDF/JS DataFactory](http://rdf.js.org/data-model-spec/#datafactory-interface) instance.
See the following lines on how to import and use the library:

```
import dataFactory from '@rdfjs/data-model'

const quad = dataFactory.quad(
  dataFactory.blankNode(),
  dataFactory.namedNode('http://schema.org/name'),
  dataFactory.literal('RDF/JS Data model')
)
```
npm package: @rdfjs/dataset
Description: An indexed implementation of the RDF/JS Dataset
Author: Thomas Bergwinkl
Latest version: 2.0.2

# @rdfjs/dataset
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/dataset/test.yaml?branch=master)](https://github.com/rdfjs-base/dataset/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/dataset.svg)](https://www.npmjs.com/package/@rdfjs/dataset)

An indexed implementation of the [RDF/JS Dataset](https://rdf.js.org/dataset-spec/) based on the great work by [Ruben Verborgh](https://github.com/RubenVerborgh) in [N3.js](https://github.com/rdfjs/N3.js).

## Usage

Use the following command to add the package as a dependency to your project:

```bash
npm install @rdfjs/dataset --save
```

The main entry point of the package exports an [RDF/JS DatasetCoreFactory](https://rdf.js.org/dataset-spec/#datasetcorefactory-interface) instance.
See the following lines on how to import and use the library:

```
import dataFactory from '@rdfjs/data-model'
import datasetFactory from '@rdfjs/dataset'

const quad = dataFactory.quad(
  dataFactory.blankNode(),
  dataFactory.namedNode('http://schema.org/name'),
  dataFactory.literal('RDF/JS Dataset')
)

const dataset = datasetFactory.dataset([quad])
```
npm package: @rdfjs/environment
Description: A flexible RDF/JS factory
Author: Thomas Bergwinkl
Latest version: 1.0.0

# @rdfjs/environment

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/environment/test.yaml?branch=master)](https://github.com/rdfjs-base/environment/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/environment.svg)](https://www.npmjs.com/package/@rdfjs/environment)

This package provides a flexible RDF/JS factory.
The `Environment` class takes one or more RDF/JS factory classes and creates a new, merged instance.
All factory methods will use the `Environment` instance as factory to create new object instances.
Clones can be created to manipulate an instance isolated from other instances.

## Usage

The main export of the package is the `Environment` class.
It can be imported like this:

```javascript
import Environment from '@rdfjs/environment'
```

The following example shows how to build an environment that is a combined factory of a [DataFactory](http://rdf.js.org/data-model-spec/#datafactory-interface) and [DatasetCoreFactory](https://rdf.js.org/dataset-spec/#datasetcorefactory-interface): 

```javascript
import DataFactory from '@@rdfjs/data-model/Factory.js'
import DatasetFactory from '@rdfjs/dataset/Factory.js'
import Environment from '@rdfjs/environment'

const env = new Environment([DataFactory, DatasetFactory])
```

### Environment(factories)

Creates a new `Environment` instance.
`factories` must be an iterable (e.g., `Array`) of RDF/JS factory classes.

#### clone()

This method creates a new, isolated `Environment` instance with the same set of factories and clones of the instance data.
npm package: @rdfjs/formats
Description: Bundle of RDF/JS parsers and serializers
Author: Thomas Bergwinkl
Latest version: 4.0.1

# @rdfjs/formats

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/formats/test.yaml?branch=master)](https://github.com/rdfjs-base/formats/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/formats.svg)](https://www.npmjs.com/package/@rdfjs/formats)

This module bundles parsers and serializers for the most common RDF formats.
Instances of [SinkMap](https://github.com/rdfjs-base/sink-map) are used to handle different media types.

## Usage

The formats object has a `parsers` and `serializers` property.
Each is an instance of `SinkMap` with the most common RDF media types as key.
The formats object is exported as default and can be imported like this:

```javascript
import formats from '@rdfjs/formats'
```

### Pretty-Print Serializers

The default bundle of serializers is optimized for streaming.
The pretty-print formats bundle can be used if a more human-readable output is required.
It can be imported like this:

### Factory

A factory that takes care of parsers and serializers.
An additional `.formats` object will be attached to the environment.
That object is compatible with the data structure of [@rdfjs/formats-common](https://github.com/rdfjs-base/formats-common).
The `.formats` object has an additional `.import()` function to import other format bundles.
The following code shows how to import the [@rdfjs/formats-common](https://github.com/rdfjs-base/formats-common) bundle:


```javascript
import formats from '@rdfjs/formats/pretty.js'
```

## Example

The following example uses the parser for the media type `text/turtle` to parse the given string.
The quads emitted by the `data` event are written to the console:

```javascript
import formats from '@rdfjs/formats'
import { Readable } from 'readable-stream'

const input = Readable.from([`
  PREFIX s: <http://schema.org/>

  [] a s:Person;
    s:jobTitle "Professor";
    s:name "Jane Doe";
    s:telephone "(425) 123-4567";
    s:url <http://www.janedoe.com>.
`])

const output = formats.parsers.import('text/turtle', input)

output.on('data', quad => {
  console.log(`quad: ${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})

output.on('prefix', (prefix, ns) => {
  console.log(`prefix: ${prefix} ${ns.value}`)
})
```
npm package: @rdfjs/formats-common
Description: Parsers and serializers for common RDF formats
Author: Thomas Bergwinkl
Latest version: 3.1.0

# @rdfjs/formats-common
[![build status](https://img.shields.io/github/workflow/status/rdfjs-base/formats-common/Test)](https://github.com/rdfjs-base/formats-common/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/formats-common.svg)](https://www.npmjs.com/package/@rdfjs/formats-common)

This module bundles parsers and serializers for the most common RDF formats.
Instances of [SinkMap](https://github.com/rdfjs-base/sink-map) are used to handle different media types.

## Usage

The formats object has a `parsers` and `serializers` property.
Each of it is an instance of `SinkMap` with the most common RDF media types as key.

## Example

```javascript
import formats from '@rdfjs/formats-common'
import { Readable } from 'readable-stream'

const input = Readable.from([`
  PREFIX s: <http://schema.org/>

  [] a s:Person;
    s:jobTitle "Professor";
    s:name "Jane Doe";
    s:telephone "(425) 123-4567";
    s:url <http://www.janedoe.com>.
`])

const output = formats.parsers.import('text/turtle', input)

output.on('data', quad => {
  console.log(`quad: ${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})

output.on('prefix', (prefix, ns) => {
  console.log(`prefix: ${prefix} ${ns.value}`)
})
```
npm package: @rdfjs/io
Description: I/O operations for RDF/JS streams and datasets
Author: Thomas Bergwinkl
Latest version: 1.2.0

# @rdfjs/io

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/io/test.yaml?branch=master)](https://github.com/rdfjs-base/io/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/io.svg)](https://www.npmjs.com/package/@rdfjs/io)

This package provides I/O operations for RDF/JS streams and datasets.

## Usage

Depending on which kind of objects should be used for the I/O operations, there are three different options to import this package:

To import both, streams and datasets operations, use the main entrypoint:

```js
import * as io from '@rdfjs/io'
```

If only dataset operations are required:

```js
import * as datasetIo from '@rdfjs/io/dataset.js'
```

And, if only stream operations are required:

```js
import * as streamIo from '@rdfjs/io/stream.js'
```

### Factory Argument

All operations require a factory argument.
The factory must be an [Environment](https://www.npmjs.com/package/@rdfjs/environment) that bundles multiple other factories.
[FetchFactory](https://www.npmjs.com/package/@rdfjs/fetch-lite) and [FormatsFactory](https://www.npmjs.com/package/@rdfjs/formats) are required for the stream operations.
Additionally, the [DatasetFactory](https://www.npmjs.com/package/@rdfjs/dataset) is required for dataset operations.

## Examples

The following example loads a dataset from the given URL:

```js
import * as io from '@rdfjs/io'
import factory from './factory.js'

const url = 'https://housemd.rdf-ext.org/person/gregory-house'
const dataset = await io.dataset.fromURL(url, { factory })
```

The following example loads the quads of the given URL as a stream of quads:

```js
import * as io from '@rdfjs/io'
import factory from './factory.js'

const url = 'https://housemd.rdf-ext.org/person/gregory-house'
const stream = io.stream.fromURL(url, { factory })
```
npm package: @rdfjs/namespace
Description: Named Node builder
Author: Thomas Bergwinkl
Latest version: 2.0.1

# @rdfjs/namespace
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/namespace/test.yaml?branch=master)](https://github.com/rdfjs-base/namespace/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/namespace.svg)](https://www.npmjs.com/package/@rdfjs/namespace)

[Named Node](http://rdf.js.org/) builder.

## Usage

The package exports a factory to create builders for [Named Nodes](http://rdf.js.org/#namednode-interface).
The `baseIRI` given to the factory will be used together with the parameter given to the builder to create Named Nodes.

### Factory

The factory must be called with the `baseIRI` as a string:
```javascript
const builder = namespace('http://example.org/base-iri#')
```

An optional factory can be defined:
```javascript
const builder = namespace('http://example.org/base-iri#', { factory: customFactory })
```

By default `@rdfjs/data-model` is used.

### Builder

The builder can be called in three different ways:

- function call: (`builder('property')`)
- tagged template string: (```builder`property` ```)
- property: (`builder.property`)

Calling the builder using the propery requires [Proxy](https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-objects) support.
At the moment IE11 is the only [major platform](https://caniuse.com/#feat=proxy) which doesn't support Proxy.

### Example

This example shows how to create a builder and create Named Nodes using the three different ways.
The properties of the Named Nodes are written to the console.

```javascript
import namespace from '@rdfjs/namespace'

const schema = namespace('http://schema.org/')

const hasPart = schema('hasPart')
console.log(hasPart.termType) // NamedNode
console.log(hasPart.value) // http://schema.org/hasPart

const person = schema`Person`
console.log(person.termType) // NamedNode
console.log(person.value) // http://schema.org/Person

const comment = schema.Comment
console.log(comment.termType) // NamedNode
console.log(comment.value) // http://schema.org/Comment
```
npm package: @rdfjs/normalize
Description: RDF graph normalization for RDF/JS datasets
Author: Thomas Bergwinkl
Latest version: 2.0.4

# @rdfjs/normalize
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/normalize/test.yaml?branch=master)](https://github.com/rdfjs-base/normalize/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/normalize.svg)](https://www.npmjs.com/package/@rdfjs/normalize)

RDF Dataset Normalization as described in the [spec](https://json-ld.github.io/normalization/spec/) from the Credentials W3C community group.
Subtitle is "A Standard RDF Dataset Normalization Algorithm".
npm package: @rdfjs/parser-jsonld
Description: JSON-LD parser that implements the RDFJS Sink interface using jsonld.js
Author: Thomas Bergwinkl
Latest version: 2.1.3

# @rdfjs/parser-jsonld
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/parser-jsonld/test.yaml?branch=master)](https://github.com/rdfjs-base/parser-jsonld/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/parser-jsonld.svg)](https://www.npmjs.com/package/@rdfjs/parser-jsonld)

JSON-LD parser that implements the [RDF/JS Sink interface](http://rdf.js.org/) using [jsonld-streaming-parser](https://github.com/rubensworks/jsonld-streaming-parser.js).

## Usage

Use the following command to add the package as a dependency to your project:

```bash
npm install @rdfjs/data-model --save
```

The package exports the parser as a class, so an instance must be created before it can be used.
The `.import` method, as defined in the [RDF/JS specification](http://rdf.js.org/#sink-interface), must be called to do the actual parsing.
It expects a JSON string stream or a stream which emits a single object.
The method will return a stream which emits the parsed quads.

The constructor accepts an `options` object with the following optional keys:

- `baseIRI`: Allows passing the base IRI manually to the `jsonld-streaming-parser` library.
- `context`: Allows passing a JSON-LD context manually to the `jsonld-streaming-parser` library.
- `factory`: Use an alternative RDF/JS data factory.
  By default the [reference implementation](https://github.com/rdfjs-base/data-model/) us used.

It's also possible to pass options as second argument to the `.import` method.
The options from the constructor and the `.import` method will be merged together.

### Example

This example shows how to create a parser instance and how to feed it with a stream from a string.
The parsed quads are written to the console.

```javascript
import ParserJsonld from '@rdfjs/parser-jsonld'
import { Readable } from 'stream'

const parserJsonld = new ParserJsonld()

const input = new Readable({
  read: () => {
    input.push(`{
      "@context": "http://schema.org/",
      "@type": "Person",
      "name": "Jane Doe",
      "jobTitle": "Professor",
      "telephone": "(425) 123-4567",
      "url": "http://www.janedoe.com"
    }`)
    input.push(null)
  }
})

const output = parserJsonld.import(input)

output.on('data', quad => {
  console.log(`${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})
```
npm package: @rdfjs/parser-n3
Description: N3 parser that implements the RDF/JS Sink interface
Author: Thomas Bergwinkl
Latest version: 2.1.0

# @rdfjs/parser-n3
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/parser-n3/test.yaml?branch=master)](https://github.com/rdfjs-base/parser-n3/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/parser-n3.svg)](https://www.npmjs.com/package/@rdfjs/parser-n3)

N3 parser which implements the [RDF/JS Sink interface](http://rdf.js.org/) using the [N3.js](https://github.com/rdfjs/N3.js) library.

## Usage

The package exports the parser as a class, so an instance must be created before it can be used.
The `.import` method, as defined in the [RDFJS specification](http://rdf.js.org/#sink-interface), must be called to do the actual parsing.
It expects a Turtle, Trig, N-Triples or N-Quads string stream.
The method will return a stream which emits the parsed quads.
It also emits `prefix` events as defined in the [RDF/JS specification](http://rdf.js.org/#dom-stream-prefix).

The constructor accepts an `options` object with the following optional keys:

- `baseIRI`: Allows passing the base IRI manually to the `N3.js` library.
- `factory`: Use an alternative RDF/JS data factory.
  By default the [reference implementation](https://github.com/rdfjs-base/data-model/) is used.

It's also possible to pass options as second argument to the `.import` method.
The options from the constructor and the `.import` method will be merged together.

### Example

This example shows how to create a parser instance and how to feed it with a stream from a string.
The parsed quads and the prefixes are written to the console.

```javascript
import ParserN3 from '@rdfjs/parser-n3'
import { Readable } from 'readable-stream'

const parserN3 = new ParserN3()

const input = Readable.from(`
PREFIX s: <http://schema.org/>

[] a s:Person ;
  s:jobTitle "Professor" ;
  s:name "Jane Doe" ;
  s:telephone "(425) 123-4567" ;
  s:url <http://www.janedoe.com> .
`)

const output = parserN3.import(input)

output.on('data', quad => {
  console.log(`quad: ${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})

output.on('prefix', (prefix, ns) => {
  console.log(`prefix: ${prefix} ${ns.value}`)
})
```
npm package: @rdfjs/prefix-map
Description: A Map for RDF/JS prefixes
Author: Thomas Bergwinkl
Latest version: 0.1.2

# @rdfjs/prefix-map

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/prefix-map/test.yaml?branch=master)](https://github.com/rdfjs-base/prefix-map/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/prefix-map.svg)](https://www.npmjs.com/package/@rdfjs/prefix-map)

A Map for RDF/JS prefixes.

This package implements the JavaScript Map interface for RDF prefixes.
Key-Value pairs are stored with the prefix as the key as a string and the namespaces as the value in an RDF/JS NamedNode object. 
There are some additional convenience methods to handle CURIEs and prefix events of RDF/JS Quad streams.

## Usage

The package exports the constructor of the PrefixMap.
New instances with initial pairs can be created just like JavaScript `Map`s but require an additional `factory` argument:

```javascript
import rdf from '@rdfjs/data-model'
import PrefixMap from '@rdfjs/prefix-map'

// create a PrefixMap, fill it with some initial values, and hand over the data model factory
const prefixes = new PrefixMap([
  ['rdf', rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#')],
  ['schema', rdf.namedNode('http://schema.org')]
], { factory: rdf })

// create two NamedNodes, one with a CURIE and one with a full IRI
const personShort = rdf.namedNode('schema:Person')
const typeLong = rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') 

// convert the CURIE to a full IRI and vice versa
const personLong = prefixes.resolve(personShort)
const typeShort = prefixes.shrink(typeLong)

// write the result to the console
console.log(personLong.value) // -> http://schema.org/Person
console.log(typeShort.value) // -> rdf:type
```
npm package: @rdfjs/serializer-jsonld
Description: JSON-LD serializer that implements the RDF/JS Sink interface
Author: Thomas Bergwinkl
Latest version: 2.0.1

# @rdfjs/serializer-jsonld
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/serializer-jsonld/test.yaml?branch=master)](https://github.com/rdfjs-base/serializer-jsonld/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/serializer-jsonld.svg)](https://www.npmjs.com/package/@rdfjs/serializer-jsonld)

JSON-LD serializer that implements the [RDF/JS Sink interface](http://rdf.js.org/).

## Usage

The package exports the serializer as a class, so an instance must be created before it can be used.
The `.import` method, as defined in the [RDF/JS specification](http://rdf.js.org/#sink-interface), must be called to do the actual serialization.
It expects a quad stream as argument.
The method will return a stream which emits the JSON-LD as a plain object or string.

The constructor accepts an `options` object with the following optional keys:

- `encoding`: Defines the encoding of the output.
  Supported encodings are `string` and `object`.
  By default `object` is used.

It's also possible to pass options as second argument to the `.import` method.
The options from the constructor and the `.import` method will be merged together.

### Example

This example shows how to create a serializer instance and how to feed it with a stream of quads.
The object emitted by the serializer will be written to the console.

```javascript
import rdf from '@rdfjs/data-model'
import { Readable } from 'readable-stream'
import SerializerJsonld from '@rdfjs/serializer-jsonld'

const serializerJsonld = new SerializerJsonld()
const input = new Readable({
  objectMode: true,
  read: () => {
    input.push(rdf.quad(
      rdf.namedNode('http://example.org/sheldon-cooper'),
      rdf.namedNode('http://schema.org/givenName'),
      rdf.literal('Sheldon')))
    input.push(rdf.quad(
      rdf.namedNode('http://example.org/sheldon-cooper'),
      rdf.namedNode('http://schema.org/familyName'),
      rdf.literal('Cooper')))
    input.push(rdf.quad(
      rdf.namedNode('http://example.org/sheldon-cooper'),
      rdf.namedNode('http://schema.org/knows'),
      rdf.namedNode('http://example.org/amy-farrah-fowler')))
    input.push(null)
  }
})
const output = serializerJsonld.import(input)

output.on('data', jsonld => {
  console.log(jsonld)
})
```
npm package: @rdfjs/serializer-ntriples
Description: N-Triples serializer that implements the RDF/JS Sink interface
Author: Thomas Bergwinkl
Latest version: 2.0.1

# @rdfjs/serializer-ntriples
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/serializer-ntriples/test.yaml?branch=master)](https://github.com/rdfjs-base/serializer-ntriples/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/serializer-ntriples.svg)](https://www.npmjs.com/package/@rdfjs/serializer-ntriples)

N-Triples serializer that implements the [RDF/JS Sink interface](http://rdf.js.org/).

## Usage

The package exports the serializer as a class, so an instance must be created before it can be used.
The `.import` method, as defined in the [RDF/JS specification](http://rdf.js.org/#sink-interface), must be called to do the actual serialization.
It expects a quad stream as argument.
The method will return a stream which emits N-Triples as strings.
The constructor doesn't need any options.

### Example

This example shows how to create a serializer instance and how to feed it with a stream of quads.
The N-Triples string emitted by the serializer will be written to the console.

```javascript
import rdf from '@rdfjs/data-model'
import { Readable } from 'readable-stream'
import SerializerNtriples from '@rdfjs/serializer-ntriples'

const serializerNtriples = new SerializerNtriples()
const input = Readable.from([
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/givenName'),
    rdf.literal('Sheldon')
  ),
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/familyName'),
    rdf.literal('Cooper')
  ),
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/knows'),
    rdf.namedNode('http://example.org/amy-farrah-fowler')
  )  
])
const output = serializerNtriples.import(input)

output.on('data', ntriples => {
  console.log(ntriples.toString())
})
```
npm package: @rdfjs/sink
Description: Abstract RDF/JS Sink Interface implementation
Author: Thomas Bergwinkl
Latest version: 2.0.1

# @rdfjs/sink

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/sink/test.yaml?branch=master)](https://github.com/rdfjs-base/sink/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/sink.svg)](https://www.npmjs.com/package/@rdfjs/sink)

The @rdfjs/sink package provides a wrapper for [stream](http://rdf.js.org/stream-spec/#stream-interface) classes implementing the [Sink](http://rdf.js.org/stream-spec/#sink-interface) interface.
It instantiates stream objects in the import method and forwards the options to the constructor.
npm package: @rdfjs/sink-map
Description: Map for RDF/JS Sinks including shortcut methods
Author: Thomas Bergwinkl
Latest version: 2.0.1

# @rdfjs/sink-map

[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/sink-map/test.yaml?branch=master)](https://github.com/rdfjs-base/sink-map/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/sink-map.svg)](https://www.npmjs.com/package/@rdfjs/sink-map)

Map for [RDF/JS Sink](http://rdf.js.org/stream-spec/#sink-interface) including shortcut methods.

## Usage

The package provides Map from a string key to a Sink with a shortcut for `.import`.
Typical it's used to store parsers or serializers for specific media types.
As SinkMap extends from the [ECMAScript 2015 Map](https://www.ecma-international.org/ecma-262/6.0/#sec-map-objects) and doesn't overload any standard methods, methods like `set`, `get`, `has` or `delete` can be used as defined in the specification.

### Create a SinkMap
The constructor accepts arrays with key/sink pairs to fill the map:

```javascript
const map = new SinkMap([
  ['text/turtle', new ParserN3()]
])
```

It's also possible to create an empty map and add or extend it later using the `.set()` method:

```javascript
const map = new SinkMap()

map.set('text/turtle') = new ParserN3()
```

### Find a Sink

The `.get` method searches for the matching Sink and returns it:

```javascript
const map = new SinkMap([...])

const sink = map.get('text/turtle')

if (sink) {
  // found
} else {
  // not found
}
```

### Import shortcut

Usually you want to call the `.import` method of the matching Sink.
The map provides a shortcut for this.
It also has a `.import` method, but requires additionally the key as the first argument.
It returns `null` if no matching sink was found:

```javascript
const map = new SinkMap([...])

const input = fs.createReadStream('..')
const output = map.import('text/turtle', input)

if (output) {
  // found
} else {
  // not found
}
```

### Example

Here is a complete example where the map is used to store parsers and the `.import` shortcut is used to parse a string input:

```javascript
import SinkMap from '@rdfjs/sink-map'
import ParserN3 from '@rdfjs/parser-n3'
import { Readable } from 'readable-stream'

const map = new SinkMap([
  ['text/turtle', new ParserN3()]
])

const input = new Readable({
  read: () => {
    input.push(`
      PREFIX s: <http://schema.org/>

      [] a s:Person ;
        s:jobTitle "Professor" ;
        s:name "Jane Doe" ;
        s:telephone "(425) 123-4567" ;
        s:url <http://www.janedoe.com> .
    `)
    input.push(null)
  }
})

const output = map.import('text/turtle', input)

output.on('data', quad => {
  console.log(`${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})
```