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

rdf-store-inmemory

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdf-store-inmemory - npm Package Compare versions

Comparing version 0.1.2 to 0.3.0-rc1

test/test.js

126

index.js

@@ -1,80 +0,84 @@

'use strict';
var util = require('util')
var AbstractStore = require('rdf-store-abstract')
function InMemoryStore (rdf) {
var graphs = {};
function iriToKey (iri) {
// default graph
if (iri === true) {
return iri
}
this.graph = function (iri, callback) {
var graph = null;
// all graphs
if (!iri) {
return null
}
if (iri === undefined) {
graph = rdf.createGraph();
return iri.toString()
}
this.forEach(function (toAdd) {
graph.addAll(toAdd);
});
} else if (iri in graphs) {
graph = graphs[iri];
}
function InMemoryStore (options) {
options = options || {}
callback(graph);
};
this.rdf = options.rdf || require('rdf-ext')
this.graphs = {}
this.match = function (iri, subject, predicate, object, callback, limit) {
this.graph(iri, function (graph) {
if (!graph) {
callback(null);
} else {
callback(graph.match(subject, predicate, object, limit));
}
});
};
AbstractStore.call(this)
}
this.add = function (iri, graph, callback) {
graphs[iri] = rdf.createGraph();
graphs[iri].addAll(graph);
util.inherits(InMemoryStore, AbstractStore)
callback(graph);
};
InMemoryStore.prototype.add = function (iri, graph, callback) {
var self = this
this.merge = function (iri, graph, callback) {
if (iri in graphs) {
graphs[iri].addAll(graph);
} else {
graphs[iri] = graph;
}
iri = iriToKey(iri)
callback = callback || function () {}
callback(graph);
};
return new Promise(function (resolve) {
self.graphs[iri] = self.rdf.createGraph()
self.graphs[iri].addAll(graph)
this.remove = function (iri, graph, callback) {
if (iri in graphs) {
graphs[iri] = rdf.Graph.difference(graphs[iri], graph);
}
callback(null, graph)
resolve(graph)
})
}
callback(true);
};
InMemoryStore.prototype.delete = function (iri, callback) {
var self = this
this.removeMatches = function (iri, subject, predicate, object, callback) {
if (iri in graphs) {
graphs[iri].removeMatches(subject, predicate, object);
iri = iriToKey(iri)
callback = callback || function () {}
return new Promise(function (resolve) {
if (iri in self.graphs) {
delete self.graphs[iri]
}
callback(true);
};
callback()
resolve()
})
}
this.delete = function (iri, callback) {
if (iri in graphs) {
delete graphs[iri];
InMemoryStore.prototype.graph = function (iri, callback) {
var self = this
iri = iriToKey(iri)
callback = callback || function () {}
return new Promise(function (resolve) {
var graph = null
if (iri) {
graph = self.graphs[iri]
} else {
graph = self.rdf.createGraph()
Object.keys(self.graphs).forEach(function (iri) {
graph.addAll(self.graphs[iri])
})
}
callback(true);
};
callback(null, graph)
resolve(graph)
})
}
this.forEach = function (callback) {
Object.keys(graphs).forEach(function (iri) {
callback(graphs[iri], iri);
});
};
};
module.exports = InMemoryStore;
module.exports = InMemoryStore
{
"name": "rdf-store-inmemory",
"version": "0.1.2",
"version": "0.3.0-rc1",
"description": "In Memory RDF Store that follows the RDF Interface specification",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "standard",
"test": "node_modules/.bin/mocha"
},

@@ -24,3 +25,10 @@ "repository": {

},
"homepage": "https://github.com/rdf-ext/rdf-store-inmemory"
"homepage": "https://github.com/rdf-ext/rdf-store-inmemory",
"dependencies": {
"rdf-ext": "^0.3.0-rc1",
"rdf-store-abstract": "^0.3.0-rc1"
},
"devDependencies": {
"mocha": "^2.3.3"
}
}
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