forked from rdf-ext/sparql-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParsingQuery.js
More file actions
47 lines (41 loc) · 1.21 KB
/
ParsingQuery.js
File metadata and controls
47 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { array } = require('get-stream')
const StreamQuery = require('./StreamQuery')
/**
* Extends StreamQuery by materialising the SPARQL response streams
*/
class ParsingQuery extends StreamQuery {
/**
* @param {Object} init
* @param {Endpoint} init.endpoint
*/
constructor ({ endpoint }) {
super({ endpoint })
}
/**
* Performs a query which returns triples
*
* @param {string} query
* @param {Object} [options]
* @param {HeadersInit} [options.headers] HTTP request headers
* @param {'get'|'postUrlencoded'|'postDirect'} [options.operation='get']
* @return {Promise<Quad[]>}
*/
async construct (query, options = {}) {
const stream = await super.construct(query, options)
return array(stream)
}
/**
* Performs a SELECT query which returns binding tuples
*
* @param {string} query
* @param {Object} [options]
* @param {HeadersInit} [options.headers] HTTP request headers
* @param {'get'|'postUrlencoded'|'postDirect'} [options.operation='get']
* @return {Promise<Array<Object.<string, Term>>>}
*/
async select (query, options = {}) {
const stream = await super.select(query, options)
return array(stream)
}
}
module.exports = ParsingQuery