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

@graphy/core.data.factory

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphy/core.data.factory - npm Package Compare versions

Comparing version 3.0.6 to 3.1.0

143

main.js

@@ -64,2 +64,6 @@

toString() {
return this.concise();
}
equals(h_other) {

@@ -122,2 +126,4 @@ return this === h_other

const KT_RDF_TYPE = new NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type');
KT_RDF_TYPE.isRdfTypeAlias = true; // for serialization
const KT_RDF_LANG_STRING = new NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString');

@@ -139,2 +145,6 @@

if('string' === typeof z_datatype_or_lang) {
// remove optional '@' character from beginning
if('@' === z_datatype_or_lang[0]) z_datatype_or_lang = z_datatype_or_lang.slice(1);
// save fields
this.language = z_datatype_or_lang.toLowerCase();

@@ -208,2 +218,8 @@ this.datatype = KT_RDF_LANG_STRING;

class Literal_Integer extends Literal {
static from(s_literal) {
let kt = new Literal_Integer(+s_literal);
kt.value = s_literal;
return kt;
}
constructor(x_value) {

@@ -232,2 +248,8 @@ super(x_value+'');

class Literal_Double extends Literal {
static from(s_literal) {
let kt = new Literal_Double(+s_literal);
kt.value = s_literal;
return kt;
}
constructor(x_value) {

@@ -254,2 +276,8 @@ super(x_value+'');

class Literal_Decimal extends Literal {
static from(s_literal) {
let kt = new Literal_Decimal(+s_literal);
kt.value = s_literal;
return kt;
}
constructor(x_value) {

@@ -278,2 +306,8 @@ super(x_value+'');

class Literal_Boolean extends Literal {
static from(s_literal) {
let kt = new Literal_Boolean(+s_literal);
kt.value = s_literal;
return kt;
}
constructor(b_value) {

@@ -304,4 +338,4 @@ super(b_value+'');

terse() {
return 'INF';
terse(h_prefixes) {
return '"INF"^^'+KT_XSD_DOUBLE.terse(h_prefixes);
}

@@ -318,4 +352,4 @@ } Object.assign(Literal_PositiveInfinity.prototype, {

terse() {
return '-INF';
terse(h_prefixes) {
return '"-INF"^^'+KT_XSD_DOUBLE.terse(h_prefixes);
}

@@ -332,4 +366,4 @@ } Object.assign(Literal_NegativeInfinity.prototype, {

terse() {
return 'NaN';
terse(h_prefixes) {
return '"NaN"^^'+KT_XSD_DOUBLE.terse(h_prefixes);
}

@@ -365,2 +399,33 @@ } Object.assign(Literal_NaN.prototype, {

function EphemeralBlankNode() {}
EphemeralBlankNode.prototype = Object.assign(
Object.create(BlankNode.prototype), {
isAnonymous: true,
isEphemeral: true,
concise() {
return '_:#'+this.value;
},
terse() {
return '[]';
},
verbose() {
return '_:'+this.value;
},
isolate() {
return {
termType: 'BlankNode',
value: this.value,
};
},
equals() {
return false;
},
});
Object.defineProperty(EphemeralBlankNode.prototype, 'value', {
get() {
return '_'+uuid_v4();
},
});
function DefaultGraph() {}

@@ -461,18 +526,4 @@ DefaultGraph.prototype = Object.assign(

const H_NO_GRAPH = new NoGraph();
function Triple(h_subject, h_predicate, h_object) {
this.subject = h_subject;
this.predicate = h_predicate;
this.object = h_object;
this.graph = H_NO_GRAPH;
} Triple.prototype = Object.assign(
Object.create(Quad.prototype, {
// equals(y_other) {
// return this === y_other
// || (this.object.equals(y_other.object)
// && this.subject.equals(y_other.subject)
// && this.predicate.equals(y_other.predicate));
// },
}));
let g_raw = {

@@ -496,11 +547,11 @@ namedNode(p_iri) {

integer(w) {
return new Literal_Integer(w);
return Literal_Integer.from(w);
},
double(w) {
return new Literal_Double(w);
return Literal_Double.from(w);
},
decimal(w) {
return new Literal_Decimal(w);
return Literal_Decimal.from(w);
},

@@ -515,3 +566,2 @@

const factory = module.exports = {

@@ -550,2 +600,10 @@ concise,

ephemeral() {
return new EphemeralBlankNode();
},
anonymous() {
return new EphemeralBlankNode();
},
blankNode(z_label) {

@@ -555,3 +613,3 @@ // no label given, generate a UUID

// eslint-disable-next-line no-undef
return new BlankNode(uuid_v4(), true);
return new BlankNode('_'+uuid_v4(), true);
}

@@ -785,4 +843,7 @@ // label given

// warn
triple(h_subject, h_predicate, h_object) {
return new Triple(h_subject, h_predicate, h_object);
let e_stack = new Error('It is strongly encouraged to use .quad() instead of .triple()');
console.warn(e_stack.stack.replace(/^(\s*)Error:/, '$1Warning:'));
return new Quad(h_subject, h_predicate, h_object);
},

@@ -869,4 +930,8 @@

if('_' === sct_node[0]) {
if(':' !== sct_node[1]) throw new Error(`invliad concise-term string, prefixes are not allowed to start with an underscore: ${sct_node}`);
if(':' !== sct_node[1]) throw new Error(`Invliad concise-term string, prefixes are not allowed to start with an underscore: ${sct_node}`);
// interpret ephemeral hint
if('#' === sct_node[2] || 2 === sct_node.length) return factory.ephemeral();
// create blank node
return factory.blankNode(sct_node.slice(2));

@@ -879,2 +944,11 @@ }

// construct a named node
c1_named_node(sc1_node, h_prefixes={}) {
// rdf:type shortcut
if('a' === sc1_node) return KT_RDF_TYPE;
// other
return factory.c1_node_explicit(sc1_node, h_prefixes);
},
// construct a term object from a concise term string for nodes (no shortcuts)

@@ -958,3 +1032,3 @@ c1_node_explicit(sct_node, h_prefixes={}) {

else {
// anonymous blank node
// auto blank node
let k_hop = factory.blankNode();

@@ -992,3 +1066,3 @@

if(b_nested) {
// anonymous blank node
// auto blank node
let k_hop = factory.blankNode();

@@ -1011,3 +1085,3 @@

else {
// anonymous blank node
// auto blank node
let k_hop = factory.blankNode();

@@ -1096,3 +1170,10 @@

to: {
boolean: s_boolean => Literal_Boolean.from(s_boolean),
integer: s_integer => Literal_Integer.from(s_integer),
decimal: s_decimal => Literal_Decimal.from(s_decimal),
double: s_double => Literal_Double.from(s_double),
},
/**

@@ -1099,0 +1180,0 @@ * @param {Object} config -

{
"name": "@graphy/core.data.factory",
"version": "3.0.6",
"version": "3.1.0",
"description": "Create instances of Terms and Triples/Quads. Implements @RDFJS DataFactory",

@@ -27,3 +27,6 @@ "keywords": [

"uri-js": "^4.2.2"
},
"engines": {
"node": ">=8.4.0"
}
}
}
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