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.7.0 to 2.0.0

CHANGELOG.md

1

index.d.ts
export * from "./lib/SparqlJsonParser";
export * from "./lib/SparqlJsonBindingsTransformer";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -14,3 +18,2 @@ if (k2 === undefined) k2 = k;

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

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

* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.
* @return {NodeJS.ReadableStream} A stream of bindings.
* @return {Promise<boolean>} The response boolean.
*/

@@ -47,0 +47,0 @@ parseJsonBooleanStream(sparqlResponseStream: NodeJS.ReadableStream): Promise<boolean>;

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

const rdf_data_factory_1 = require("rdf-data-factory");
const SparqlJsonBindingsTransformer_1 = require("./SparqlJsonBindingsTransformer");
const readable_stream_1 = require("readable-stream");
// tslint:disable-next-line:no-var-requires
const JsonParser = require('jsonparse');
/**

@@ -37,10 +39,20 @@ * Parser for the SPARQL 1.1 Query Results JSON format.

sparqlResponseStream.on('error', errorListener);
const variables = [];
sparqlResponseStream
.pipe(require('JSONStream').parse('head.vars.*').on('error', errorListener))
.on('data', (variable) => variables.push(this.dataFactory.variable(variable)))
.on('end', () => resultStream.emit('variables', variables));
const jsonParser = new JsonParser();
jsonParser.onError = errorListener;
jsonParser.onValue = (value) => {
if (jsonParser.key === "vars" && jsonParser.stack.length === 2 && jsonParser.stack[1].key === 'head') {
resultStream.emit('variables', value.map((v) => this.dataFactory.variable(v)));
}
else if (typeof jsonParser.key === 'number' && jsonParser.stack.length === 3 && jsonParser.stack[1].key === 'results' && jsonParser.stack[2].key === 'bindings') {
resultStream.push(this.parseJsonBindings(value));
}
};
const resultStream = sparqlResponseStream
.pipe(require('JSONStream').parse('results.bindings.*').on('error', errorListener))
.pipe(new SparqlJsonBindingsTransformer_1.SparqlJsonBindingsTransformer(this));
.pipe(new readable_stream_1.Transform({
objectMode: true,
transform(chunk, encoding, callback) {
jsonParser.write(chunk);
callback();
}
}));
return resultStream;

@@ -101,9 +113,16 @@ }

* @param {NodeJS.ReadableStream} sparqlResponseStream A SPARQL JSON response stream.
* @return {NodeJS.ReadableStream} A stream of bindings.
* @return {Promise<boolean>} The response boolean.
*/
parseJsonBooleanStream(sparqlResponseStream) {
return new Promise((resolve, reject) => {
sparqlResponseStream.on('error', reject);
sparqlResponseStream.pipe(require('JSONStream').parse('boolean'))
.on('data', resolve)
const parser = new JsonParser();
parser.onError = reject;
parser.onValue = (value) => {
if (parser.key === "boolean" && typeof value === 'boolean' && parser.stack.length === 1) {
resolve(value);
}
};
sparqlResponseStream
.on('error', reject)
.on('data', d => parser.write(d))
.on('end', () => reject(new Error('No valid ASK response was found.')));

@@ -110,0 +129,0 @@ });

{
"name": "sparqljson-parse",
"version": "1.7.0",
"version": "2.0.0",
"description": "Parses SPARQL JSON query results",

@@ -33,7 +33,7 @@ "keywords": [

"devDependencies": {
"@types/jest": "^26.0.0",
"@types/jest": "^28.0.0",
"@types/minimist": "^1.2.0",
"arrayify-stream": "^1.0.0",
"arrayify-stream": "^2.0.0",
"coveralls": "^3.0.0",
"jest": "^26.0.0",
"jest": "^28.0.0",
"jest-rdf": "^1.7.0",

@@ -43,6 +43,9 @@ "manual-git-changelog": "^1.0.0",

"streamify-string": "^1.0.1",
"ts-jest": "^26.0.0",
"ts-jest": "^28.0.0",
"ts-loader": "^9.3.1",
"tslint": "^6.0.0",
"tslint-eslint-rules": "^5.3.1",
"typescript": "^4.3.5"
"typescript": "^4.3.5",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},

@@ -52,3 +55,3 @@ "jest": {

"ts-jest": {
"tsConfig": "test/tsconfig.json"
"tsconfig": "test/tsconfig.json"
}

@@ -85,6 +88,9 @@ },

"@rdfjs/types": "*",
"@types/node": "^13.1.0",
"JSONStream": "^1.3.3",
"rdf-data-factory": "^1.1.0"
}
"@types/readable-stream": "^2.3.13",
"buffer": "^6.0.3",
"jsonparse": "^1.3.1",
"rdf-data-factory": "^1.1.0",
"readable-stream": "^4.0.0"
},
"sideEffects": false
}
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