# sparql-iterator

> Linked Data Fragments Client

Latest version **2.0.8** (published 2018-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install sparql-iterator
pnpm add sparql-iterator
yarn add sparql-iterator
bun add sparql-iterator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2018-01-15 |
| First published | 2018-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | e-e-e |

## Links

- npm: https://www.npmjs.com/package/sparql-iterator
- Repository: https://github.com/e-e-e/sparql-iterator
- Homepage: https://github.com/e-e-e/sparql-iterator#readme
- Issues: https://github.com/e-e-e/sparql-iterator/issues
- npm.io page: https://npm.io/package/sparql-iterator

## Dependencies (4)

- [n3](https://npm.io/package/n3.md) ^0.8.1
- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [sparqljs](https://npm.io/package/sparqljs.md) ^1.3.0
- [asynciterator](https://npm.io/package/asynciterator.md) ^1.1.0

## Recent versions

- 2.0.8 (latest) — 2018-01-15
- 2.0.6 — 2018-01-14
- 2.0.5 — 2018-01-14

## README

# Sparql Iterator

[![Build Status](https://travis-ci.org/e-e-e/sparql-iterator.svg?branch=master)](https://travis-ci.org/e-e-e/sparql-iterator)
[![Coverage Status](https://coveralls.io/repos/github/e-e-e/sparql-iterator/badge.svg?branch=master)](https://coveralls.io/github/e-e-e/sparql-iterator?branch=master)

A fast and simple [SPARQL](https://www.w3.org/TR/sparql11-protocol/) query interface for [Linked Data Fragments](http://linkeddatafragments.org) and [hyper-graph-db](https://github.com/e-e-e/hyper-graph-db).

*Note:* This is a fork of [Linked Data Fragments Client](https://github.com/LinkedDataFragments/Client.js) which includes only the code for the sparql interator. It has been modified to accept hyper-graph-db as a client.

## Installation

```
npm install sparql-iterator
```

## Simple Use

First, create or connect to a `HyperGraph` representation of a dataset.
<br>
Then create a `SparqlIterator` to evaluate SPARQL queries on that dataset.

```JavaScript
var SparqlIterator = require('sparql-iterator');
var hypergraph = require('hyper-graph-db');

var graph = new hypergraph(storage, key);
var query = 'SELECT * { ?s ?p <http://dbpedia.org/resource/Belgium>. ?s ?p ?o } LIMIT 100',
    results = new SparqlIterator(query, { hypergraph: graph });
results.on('data', function (result) { console.log(result); });
```

## API

#### var stream = new SparqlIterator(query, options);

Returns a new stream of results. Expects query to be a valid SPARQL query as a string or an object representing a parsed query (refer to [SPARQL.js](https://www.npmjs.com/package/sparqljs)).

Expects `options` argument to be an object passing in the client to use.
Either:
```js
{
  hypergraph: instance of HyperGraph,
}
```
or:
```js
{
  fragmentsClient: an instance of LinkedDataFragementsClient,
}
```

#### stream.on('data', cb)

A `data` event is fired for each new result that matches the SPARQL query.

#### stream.on('end', cb)

A `end` event is fired when the query has completed.

#### stream.on('error', cb)

A `error` event is fired when an error has occurred.

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