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

modelld

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modelld - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

76

lib/field.js

@@ -20,4 +20,2 @@ 'use strict';

var _validUrl = require('valid-url');
var _util = require('./util');

@@ -80,2 +78,3 @@

listed: options.listed,
namedNode: options.namedNode,
sourceConfig: sourceConfig

@@ -124,2 +123,4 @@ });

* (public) or unlisted (private).
* @param {Boolean=} options.namedNode - Whether or not this field is a
* NamedNode.
* @param {Object} options.sourceConfig - A configuration object containing

@@ -142,2 +143,3 @@ * the default listed and unlisted source graphs, and a mapping of all source

var value = _ref.value;
var namedNode = _ref.namedNode;
var listed = _ref.listed;

@@ -159,3 +161,3 @@ var originalObject = _ref.originalObject;

this.originalObject = originalObject;
this.value = originalObject.value;
this.value = rdfToJs(originalObject);
}

@@ -169,2 +171,5 @@ if ((0, _util.isDefined)(originalSource)) {

}
if ((0, _util.isDefined)(namedNode)) {
this.namedNode = namedNode || false;
}
if ((0, _util.isDefined)(listed)) {

@@ -212,3 +217,3 @@ this.listed = listed;

}
return rdf.namedNode(sourceURI);
return rdf.NamedNode.fromValue(sourceURI);
}

@@ -231,3 +236,4 @@

object = (0, _clone2.default)(this.originalObject);
object.value = this.value;
// Convert the native JS value back to the corresponding RDF string value
object.value = this.originalObject.constructor.fromValue(this.value).value;
if ((0, _util.isDefined)(object.uri)) {

@@ -237,3 +243,3 @@ object.uri = this.value;

} else {
object = (0, _validUrl.isUri)(this.value) ? rdf.namedNode(this.value) : rdf.Literal.fromValue(this.value);
object = this.namedNode ? rdf.NamedNode.fromValue(this.value) : rdf.Literal.fromValue(this.value);
}

@@ -293,2 +299,4 @@

var listed = _ref2$listed === undefined ? null : _ref2$listed;
var _ref2$namedNode = _ref2.namedNode;
var namedNode = _ref2$namedNode === undefined ? false : _ref2$namedNode;

@@ -300,2 +308,3 @@ return new Field({

value: value !== null ? value : this.value,
namedNode: namedNode,
listed: listed !== null ? listed : this.listed,

@@ -338,2 +347,55 @@ sourceConfig: this._sourceConfig

return Field;
}();
}();
/**
* Extracts the value of an rdf node into the native JS representation of that
* node's type/value. For example, it will extract booleans from a node with a
* datatype of xsd:boolean and a value of '0' or '1'.
*
* @param {Object} node - The rdf node object.
* @returns The value of that node.
*/
function rdfToJs(node) {
var value = void 0;
var rdfVal = node.value;
var datatype = node.datatype;
var throwError = function throwError() {
throw new Error('Cannot parse rdf type/value to JS value. Given value [' + rdfVal + '] of type [' + datatype + '].');
};
if (datatype) {
var XMLSchema = 'http://www.w3.org/2001/XMLSchema#';
switch (datatype.value) {
case XMLSchema + 'boolean':
if (rdfVal === '1') {
value = true;
} else if (rdfVal === '0') {
value = false;
} else {
throwError();
}
break;
case XMLSchema + 'dateTime':
// Format of date string can be found at: http://books.xmlschemata.org/relaxng/ch19-77049.html
value = new Date(rdfVal);
break;
case XMLSchema + 'decimal':
case XMLSchema + 'double':
value = Number.parseFloat(rdfVal);
break;
case XMLSchema + 'integer':
value = Number.parseInt(rdfVal);
break;
case 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString':
case XMLSchema + 'string':
default:
value = rdfVal;
break;
}
} else {
// Assume string if there's no provided datatype
value = rdfVal;
}
return value;
}

@@ -70,3 +70,3 @@ 'use strict';

var fieldCreators = {};
var subject = rdf.namedNode(subjectStr);
var subject = rdf.NamedNode.fromValue(subjectStr);
var fields = _immutable2.default.Map(Object.keys(fieldMap).reduce(function (prevFields, fieldName) {

@@ -239,2 +239,4 @@ var fieldPredicate = fieldMap[fieldName];

* @param {Boolean} newFieldOptions.listed - the new field's listed value.
* @param {Boolean} newFieldOptions.namedNode - whether the new field is a
* named node or not.
* @returns {Model} - the updated model.

@@ -259,2 +261,6 @@ */

* @param fieldValue - the new field value.
* @param {Object} FieldOptions - arguments to create the new field.
* @param {Boolean} FieldOptions.listed - the new field's listed value.
* @param {Boolean} FieldOptions.namedNode - whether the new field is a named
* node or not.
* @returns {Model} - the updated model.

@@ -261,0 +267,0 @@ */

10

package.json
{
"name": "modelld",
"version": "0.9.0",
"version": "0.10.0",
"description": "A JavaScript API for selecting and manipulating linked data subgraphs",

@@ -18,3 +18,3 @@ "main": "lib/index.js",

"test": "nyc mocha --compilers js:babel-core/register test/**.spec.js",
"test:develop": "mocha -d -w --compilers js:babel-core/register test/*.spec.js",
"test:develop": "mocha -d -w -G --compilers js:babel-core/register test/*.spec.js",
"coverage:check": "nyc check-coverage --lines 98",

@@ -54,3 +54,3 @@ "coverage:report": "nyc report --repoprter=text-lcov --reporter=html",

"nyc": "^8.1.0",
"rdflib": "^0.9.0",
"rdflib": "^0.12.3",
"sinon": "^1.17.5",

@@ -64,6 +64,4 @@ "solid-namespace": "^0.1.0",

"lodash": "^4.14.2",
"node-uuid": "^1.4.7",
"rdflib": "^0.9.0",
"valid-url": "^1.0.9"
"node-uuid": "^1.4.7"
}
}

Sorry, the diff of this file is too big to display

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