Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sparqljson-parse

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparqljson-parse - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

1

index.d.ts
export * from "./lib/SparqlJsonParser";
export * from "./lib/SparqlJsonBindingsTransformer";

@@ -5,2 +5,3 @@ "use strict";

tslib_1.__exportStar(require("./lib/SparqlJsonParser"), exports);
tslib_1.__exportStar(require("./lib/SparqlJsonBindingsTransformer"), exports);
//# sourceMappingURL=index.js.map

@@ -12,3 +12,3 @@ /// <reference types="node" />

/**
* Convert a SPARQL JSON response to an array of bindings objects.
* Convert a SPARQL JSON bindings response to an array of bindings objects.
* @param sparqlResponse A SPARQL JSON response.

@@ -19,3 +19,3 @@ * @return {IBindings[]} An array of bindings.

/**
* Convert a SPARQL JSON response stream to a stream of bindings objects.
* Convert a SPARQL JSON bindings response stream to a stream of bindings objects.
* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.

@@ -31,2 +31,16 @@ * @return {NodeJS.ReadableStream} A stream of bindings.

parseJsonBindings(rawBindings: any): IBindings;
/**
* Convert a SPARQL JSON boolean response to a boolean.
* This will throw an error if the given reponse was not a valid boolean response.
* @param sparqlResponse A SPARQL JSON response.
* @return {IBindings[]} An array of bindings.
*/
parseJsonBoolean(sparqlResponse: any): boolean;
/**
* Convert a SPARQL JSON boolean response stream to a promise resolving to a boolean.
* This will reject if the given reponse was not a valid boolean response.
* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.
* @return {NodeJS.ReadableStream} A stream of bindings.
*/
parseJsonBooleanStream(sparqlResponseStream: NodeJS.ReadableStream): Promise<boolean>;
}

@@ -33,0 +47,0 @@ /**

@@ -16,3 +16,3 @@ "use strict";

/**
* Convert a SPARQL JSON response to an array of bindings objects.
* Convert a SPARQL JSON bindings response to an array of bindings objects.
* @param sparqlResponse A SPARQL JSON response.

@@ -25,3 +25,3 @@ * @return {IBindings[]} An array of bindings.

/**
* Convert a SPARQL JSON response stream to a stream of bindings objects.
* Convert a SPARQL JSON bindings response stream to a stream of bindings objects.
* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.

@@ -67,4 +67,29 @@ * @return {NodeJS.ReadableStream} A stream of bindings.

}
/**
* Convert a SPARQL JSON boolean response to a boolean.
* This will throw an error if the given reponse was not a valid boolean response.
* @param sparqlResponse A SPARQL JSON response.
* @return {IBindings[]} An array of bindings.
*/
parseJsonBoolean(sparqlResponse) {
if ('boolean' in sparqlResponse) {
return sparqlResponse.boolean;
}
throw new Error('No valid ASK response was found.');
}
/**
* Convert a SPARQL JSON boolean response stream to a promise resolving to a boolean.
* This will reject if the given reponse was not a valid boolean response.
* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.
* @return {NodeJS.ReadableStream} A stream of bindings.
*/
parseJsonBooleanStream(sparqlResponseStream) {
return new Promise((resolve, reject) => {
sparqlResponseStream.pipe(require('JSONStream').parse('boolean'))
.on('data', resolve)
.on('end', () => reject(new Error('No valid ASK response was found.')));
});
}
}
exports.SparqlJsonParser = SparqlJsonParser;
//# sourceMappingURL=SparqlJsonParser.js.map

13

package.json
{
"name": "sparqljson-parse",
"version": "1.0.0",
"version": "1.1.0",
"description": "Parses SPARQL JSON query results",

@@ -36,3 +36,3 @@ "keywords": [

"devDependencies": {
"@types/jest": "^21.1.8",
"@types/jest": "^23.3.0",
"@types/minimist": "^1.2.0",

@@ -43,8 +43,8 @@ "@types/rdf-data-model": "^1.0.1",

"coveralls": "^3.0.0",
"jest": "^21.2.1",
"jest": "^23.4.1",
"pre-commit": "^1.2.2",
"streamify-string": "^1.0.1",
"ts-jest": "^21.2.3",
"ts-jest": "^23.0.1",
"tslint": "^5.8.0",
"tslint-eslint-rules": "^4.1.1",
"tslint-eslint-rules": "^5.3.1",
"typescript": "^2.6.2"

@@ -64,4 +64,3 @@ },

],
"collectCoverage": true,
"mapCoverage": true
"collectCoverage": true
},

@@ -68,0 +67,0 @@ "scripts": {

@@ -5,3 +5,3 @@ # SPARQL-Results+JSON Parse

[![Coverage Status](https://coveralls.io/repos/github/rubensworks/sparqljson-parse.js/badge.svg?branch=master)](https://coveralls.io/github/rubensworks/sparqljson-parse.js?branch=master)
[![npm version](https://badge.fury.io/js/sparqljson-parse.svg)](https://www.npmjs.com/package/sparqljson-parse)
[![npm version](https://badge.fury.io/js/sparqljson-parse.svg)](https://www.npmjs.com/package/sparqljson-parse) [![Greenkeeper badge](https://badges.greenkeeper.io/rubensworks/sparqljson-parse.js.svg)](https://greenkeeper.io/)

@@ -92,2 +92,13 @@ A utility package that allows you to parse [SPARQL JSON](https://www.w3.org/TR/sparql11-results-json/) results

### Convert a full SPARQL JSON boolean response
```javascript
const sparqlJsonresponse = {
"head": {},
"boolean": true
};
sparqlJsonParser.parseJsonBoolean(sparqlJsonresponse);
// This will output true
```
### Convert a SPARQL JSON stream

@@ -100,2 +111,5 @@

`sparqlJsonParser.parseJsonBooleanStream` also takes a stream as input,
but it returns a promise that resolves to a boolean.
## License

@@ -102,0 +116,0 @@ This software is written by [Ruben Taelman](http://rubensworks.net/).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc