@graphy/core.data.factory
Advanced tools
Comparing version 3.0.5 to 3.0.6
106
main.js
@@ -546,8 +546,4 @@ | ||
} | ||
// parser or graph object given | ||
else if('object' === typeof z_label) { | ||
return new BlankNode(z_label.next_label(), true); | ||
} | ||
throw new TypeError('unexpected type for `label` parameter'); | ||
throw new TypeError(`factory.blankNode(label) expects 'label' parameter to be falsy or a string; instead found: ${z_label}`); | ||
}, | ||
@@ -562,7 +558,7 @@ | ||
// a number was given | ||
// a number was given | ||
if('number' === s_type) { | ||
// not a finite number | ||
// not a finite number | ||
if(!Number.isFinite(w_value)) { | ||
// NaN | ||
// NaN | ||
if(Number.isNaN(w_value)) { | ||
@@ -574,3 +570,3 @@ throw new Error('XSD integer cannot encode NaN. Try using double'); | ||
} | ||
// not an integer | ||
// not an integer | ||
else if(!Number.isInteger(w_value)) { | ||
@@ -582,5 +578,5 @@ throw new Error(`Number is not an integer: ${w_value}`); | ||
} | ||
// string | ||
// string | ||
else if('string' === s_type) { | ||
// empty string | ||
// empty string | ||
if('' === w_value) { | ||
@@ -590,6 +586,6 @@ throw new Error('Refusing to serialize empty string as xsd:integer'); | ||
// parse to number | ||
// parse to number | ||
let x_value = +w_value; | ||
// failed to parse or not an integer | ||
// failed to parse or not an integer | ||
if(Number.isNaN(x_value) || !Number.isInteger(x_value)) { | ||
@@ -601,9 +597,9 @@ throw new Error(`Invalid integer string: ${w_value}`); | ||
} | ||
// undefined | ||
// undefined | ||
else if('undefined' === s_type) { | ||
throw new Error('Refusing to serialize undefined value as xsd:integer'); | ||
} | ||
// other | ||
// other | ||
else { | ||
// null | ||
// null | ||
if(null === w_value) { | ||
@@ -613,3 +609,3 @@ throw new Error('Refusing to serialize null value as xsd:integer'); | ||
// invalid | ||
// invalid | ||
throw new Error('XSD integer expects a number type or integer string'); | ||
@@ -621,7 +617,7 @@ } | ||
// a number was given | ||
// a number was given | ||
if('number' === s_type) { | ||
// not a finite number | ||
// not a finite number | ||
if(!Number.isFinite(w_value)) { | ||
// NaN | ||
// NaN | ||
if(Number.isNaN(w_value)) { | ||
@@ -638,5 +634,5 @@ return new Literal_NaN(); | ||
} | ||
// string | ||
// string | ||
else if('string' === s_type) { | ||
// empty string | ||
// empty string | ||
if('' === w_value) { | ||
@@ -646,6 +642,6 @@ throw new Error('Refusing to serialize empty string as xsd:double'); | ||
// parse to number | ||
// parse to number | ||
let x_value = +w_value; | ||
// failed to parse | ||
// failed to parse | ||
if(Number.isNaN(x_value)) { | ||
@@ -657,9 +653,9 @@ throw new Error(`Invalid decimal string: ${w_value}`); | ||
} | ||
// undefined | ||
// undefined | ||
else if('undefined' === s_type) { | ||
throw new Error('Refusing to serialize undefined value as xsd:double'); | ||
} | ||
// other | ||
// other | ||
else { | ||
// null | ||
// null | ||
if(null === w_value) { | ||
@@ -669,3 +665,3 @@ throw new Error('Refusing to serialize null value as xsd:double'); | ||
// invalid | ||
// invalid | ||
throw new Error('XSD double expects a number type or double string'); | ||
@@ -677,7 +673,7 @@ } | ||
// a number was given | ||
// a number was given | ||
if('number' === s_type) { | ||
// not a finite number | ||
// not a finite number | ||
if(!Number.isFinite(w_value)) { | ||
// NaN | ||
// NaN | ||
if(Number.isNaN(w_value)) { | ||
@@ -692,5 +688,5 @@ throw new Error('XSD decimal cannot encode NaN. Try using double'); | ||
} | ||
// string | ||
// string | ||
else if('string' === s_type) { | ||
// empty string | ||
// empty string | ||
if('' === w_value) { | ||
@@ -700,6 +696,6 @@ throw new Error('Refusing to serialize empty string as xsd:decimal'); | ||
// parse to number | ||
// parse to number | ||
let x_value = +w_value; | ||
// failed to parse | ||
// failed to parse | ||
if(Number.isNaN(x_value)) { | ||
@@ -711,9 +707,9 @@ throw new Error(`Invalid decimal string: ${w_value}`); | ||
} | ||
// undefined | ||
// undefined | ||
else if('undefined' === s_type) { | ||
throw new Error('Refusing to serialize undefined value as xsd:decimal'); | ||
} | ||
// other | ||
// other | ||
else { | ||
// null | ||
// null | ||
if(null === w_value) { | ||
@@ -723,3 +719,3 @@ throw new Error('Refusing to serialize null value as xsd:decimal'); | ||
// invalid | ||
// invalid | ||
throw new Error('XSD decimal expects a number type or decimal string'); | ||
@@ -731,13 +727,13 @@ } | ||
// boolean | ||
// boolean | ||
if('boolean' === s_type) { | ||
return new Literal_Boolean(w_value); | ||
} | ||
// number | ||
// number | ||
else if('number' === s_type) { | ||
// 1 | ||
// 1 | ||
if(1 === w_value) { | ||
return new Literal_Boolean(true); | ||
} | ||
// 0 | ||
// 0 | ||
else if(0 === w_value) { | ||
@@ -747,12 +743,12 @@ return new Literal_Boolean(false); | ||
// invalid | ||
// invalid | ||
throw new Error(`Boolean value 'w_value' must be either a '1' or '0' if using numbers`); | ||
} | ||
// string | ||
// string | ||
else if('string' === s_type) { | ||
// truthy value | ||
// truthy value | ||
if(RT_BOOLEAN_TRUE.test(w_value)) { | ||
return new Literal_Boolean(true); | ||
} | ||
// falsy value | ||
// falsy value | ||
else if(RT_BOOLEAN_FALSE.test(w_value)) { | ||
@@ -762,3 +758,3 @@ return new Literal_Boolean(false); | ||
// empty string | ||
// empty string | ||
if('' === w_value) { | ||
@@ -768,12 +764,12 @@ throw new Error('Refusing to serialize empty string as xsd:boolean'); | ||
// failed to parse | ||
// failed to parse | ||
throw new Error(`Invalid boolean string: ${w_value}`); | ||
} | ||
// undefined | ||
// undefined | ||
else if('undefined' === s_type) { | ||
throw new Error('Refusing to serialize undefined value as xsd:boolean'); | ||
} | ||
// other | ||
// other | ||
else { | ||
// null | ||
// null | ||
if(null === w_value) { | ||
@@ -783,3 +779,3 @@ throw new Error('Refusing to serialize null value as xsd:boolean'); | ||
// invalid | ||
// invalid | ||
throw new Error('XSD boolean expects a boolean type or boolean string'); | ||
@@ -1043,2 +1039,4 @@ } | ||
quad(g_quad) { | ||
if(g_quad.isGraphyQuad) return g_quad; | ||
let g_from = factory.from; | ||
@@ -1049,3 +1047,3 @@ return new Quad( | ||
g_from.rdfjs_term(g_quad.object), | ||
g_from.rdfjs_term(g_quad.graph), | ||
g_quad.graph? g_from.rdfjs_term(g_quad.graph): KT_DEFAULT_GRAPH, | ||
); | ||
@@ -1052,0 +1050,0 @@ }, |
{ | ||
"name": "@graphy/core.data.factory", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Create instances of Terms and Triples/Quads. Implements @RDFJS DataFactory", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28125
2103
928