+18
-3
@@ -47,3 +47,3 @@ "use strict"; | ||
| resolvers.push(new _ComplexPathResolver.default(contextProvider)); | ||
| resolvers.push(new _JSONLDResolver.default(contextProvider)); | ||
| resolvers.push(this._jsonldResolver = new _JSONLDResolver.default(contextProvider)); | ||
| settings.parsedContext = new _jsonldContextParser.ContextParser().parse(settings.context).then(_ref => { | ||
@@ -77,5 +77,20 @@ let { | ||
| // The settings parameter is optional | ||
| if (!data) [data, settings] = [settings, null]; // Apply defaults on settings and data | ||
| if (!data) [data, settings] = [settings, null]; // Set data as subject if input as string | ||
| return this._pathProxy.createPath(Object.assign(Object.create(null), this._settings, settings), Object.assign(Object.create(null), this._data, data)); | ||
| if (typeof data === 'string') data = { | ||
| subject: data | ||
| }; // Apply defaults on data | ||
| const _data = { ...this._data, | ||
| ...data | ||
| }; // Resolve string subjects to namedNodes | ||
| if (typeof _data.subject === 'string') { | ||
| if (this._jsonldResolver) _data.subject = this._jsonldResolver.lookupProperty(_data.subject);else throw new Error('Unable to resolve string subject - try providing a context to the PathFactory'); | ||
| } // Apply defaults on settings | ||
| return this._pathProxy.createPath({ ...this._settings, | ||
| ...settings | ||
| }, _data); | ||
| } | ||
@@ -82,0 +97,0 @@ |
@@ -31,3 +31,3 @@ import PathProxy from './PathProxy'; | ||
| resolvers.push(new ComplexPathResolver(contextProvider)); | ||
| resolvers.push(new JSONLDResolver(contextProvider)); | ||
| resolvers.push(this._jsonldResolver = new JSONLDResolver(contextProvider)); | ||
| settings.parsedContext = new ContextParser().parse(settings.context).then(_ref => { | ||
@@ -61,5 +61,20 @@ let { | ||
| // The settings parameter is optional | ||
| if (!data) [data, settings] = [settings, null]; // Apply defaults on settings and data | ||
| if (!data) [data, settings] = [settings, null]; // Set data as subject if input as string | ||
| return this._pathProxy.createPath(Object.assign(Object.create(null), this._settings, settings), Object.assign(Object.create(null), this._data, data)); | ||
| if (typeof data === 'string') data = { | ||
| subject: data | ||
| }; // Apply defaults on data | ||
| const _data = { ...this._data, | ||
| ...data | ||
| }; // Resolve string subjects to namedNodes | ||
| if (typeof _data.subject === 'string') { | ||
| if (this._jsonldResolver) _data.subject = this._jsonldResolver.lookupProperty(_data.subject);else throw new Error('Unable to resolve string subject - try providing a context to the PathFactory'); | ||
| } // Apply defaults on settings | ||
| return this._pathProxy.createPath({ ...this._settings, | ||
| ...settings | ||
| }, _data); | ||
| } | ||
@@ -66,0 +81,0 @@ |
+3
-3
| { | ||
| "name": "ldflex", | ||
| "version": "2.14.0", | ||
| "version": "2.15.0", | ||
| "description": "A JavaScript DSL for querying Linked Data on the Web", | ||
@@ -37,7 +37,7 @@ "license": "MIT", | ||
| "eslint": "^8.4.0", | ||
| "eslint-plugin-jest": "^25.3.0", | ||
| "eslint-plugin-jest": "^26.0.0", | ||
| "husky": "^7.0.4", | ||
| "jest": "^27.4.3", | ||
| "n3": "^1.12.2", | ||
| "semantic-release": "^18.0.1" | ||
| "semantic-release": "^19.0.2" | ||
| }, | ||
@@ -44,0 +44,0 @@ "scripts": { |
+19
-0
@@ -143,2 +143,21 @@ # LDflex makes Linked Data in JavaScript fun | ||
| ### Modifying data | ||
| ```javascript | ||
| // Add a new value | ||
| await person['http://xmlns.com/foaf/0.1/name'].add(literal(name)); | ||
| await person['http://xmlns.com/foaf/0.1/nick'].add(literal(nickname)); | ||
| // Set a new value and override existing values | ||
| await person['http://xmlns.com/foaf/0.1/name'].set(literal(name)); | ||
| await person['http://xmlns.com/foaf/0.1/nick'].set(literal(nickname)); | ||
| // Delete object values | ||
| await person['http://xmlns.com/foaf/0.1/name'].delete(); | ||
| await person['http://xmlns.com/foaf/0.1/nick'].delete(); | ||
| // Replace object values | ||
| await person['http://xmlns.com/foaf/0.1/name'].replace(literal(oldName), literal(name)); | ||
| ``` | ||
| ### Accessing collections | ||
@@ -145,0 +164,0 @@ Handle `rdf:List`, `rdf:Bag`, `rdf:Alt`, `rdf:Seq` and `rdf:Container`. |
+18
-5
@@ -29,3 +29,3 @@ import PathProxy from './PathProxy'; | ||
| resolvers.push(new ComplexPathResolver(contextProvider)); | ||
| resolvers.push(new JSONLDResolver(contextProvider)); | ||
| resolvers.push(this._jsonldResolver = new JSONLDResolver(contextProvider)); | ||
| settings.parsedContext = new ContextParser().parse(settings.context) | ||
@@ -54,6 +54,19 @@ .then(({ contextRaw }) => contextRaw); | ||
| // Apply defaults on settings and data | ||
| return this._pathProxy.createPath( | ||
| Object.assign(Object.create(null), this._settings, settings), | ||
| Object.assign(Object.create(null), this._data, data)); | ||
| // Set data as subject if input as string | ||
| if (typeof data === 'string') | ||
| data = { subject: data }; | ||
| // Apply defaults on data | ||
| const _data = { ...this._data, ...data }; | ||
| // Resolve string subjects to namedNodes | ||
| if (typeof _data.subject === 'string') { | ||
| if (this._jsonldResolver) | ||
| _data.subject = this._jsonldResolver.lookupProperty(_data.subject); | ||
| else | ||
| throw new Error('Unable to resolve string subject - try providing a context to the PathFactory'); | ||
| } | ||
| // Apply defaults on settings | ||
| return this._pathProxy.createPath({ ...this._settings, ...settings }, _data); | ||
| } | ||
@@ -60,0 +73,0 @@ } |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
214694
0.92%5436
0.59%215
9.69%