New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tpluscode/rdfine

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tpluscode/rdfine - npm Package Compare versions

Comparing version 0.4.23 to 0.4.24

6

CHANGELOG.md
# Change Log
## 0.4.24
### Patch Changes
- c1e1e19: Allow properties to return both arrays/lists as well as single values
## 0.4.23

@@ -4,0 +10,0 @@

3

lib/decorators/property/index.d.ts

@@ -8,4 +8,5 @@ import { Term } from 'rdf-js';

import resourcePropertyDecorator from '../property/resource';
declare type PropertyReturnKind = 'single' | 'array' | 'list';
export interface AccessorOptions {
values?: 'array' | 'list';
values?: PropertyReturnKind | PropertyReturnKind[];
path?: ArrayOrSingle<PropRef | EdgeTraversalFactory>;

@@ -12,0 +13,0 @@ strict?: true;

@@ -69,3 +69,9 @@ "use strict";

const { fromTerm, toTerm, assertSetValue, valueTypeName, initial, strict, compare, subjectFromAllGraphs } = options;
let values = options.values || 'single';
let values = ['single'];
if (Array.isArray(options.values)) {
values = options.values;
}
else if (options.values) {
values = [options.values];
}
const getPath = () => Array.isArray(options.path)

@@ -81,3 +87,3 @@ ? path_1.toEdgeTraversals(proto, options.path)

if (subjectFromAllGraphs || crossesBoundaries) {
values = 'array';
values = ['array'];
}

@@ -93,12 +99,12 @@ const returnValues = nodes.map((obj, index) => {

}).filter(filter_1.onlyUnique(compare));
if (values === 'array') {
if (values.includes('array') && returnValues.length !== 1) {
return returnValues;
}
if (values === 'list') {
if (values.includes('list') && Array.isArray(returnValues[0])) {
return returnValues[0] || [];
}
if (returnValues.length > 1) {
if (returnValues.length > 1 && !values.includes('array')) {
throw new Error(`${name}: Multiple terms found where 0..1 was expected`);
}
if (Array.isArray(returnValues[0])) {
if (Array.isArray(returnValues[0]) && !values.includes('list')) {
throw new Error(`${name}: RDF List found where 0..1 object was expected`);

@@ -109,6 +115,6 @@ }

}
return returnValues[0];
return values.includes('single') ? returnValues[0] : returnValues;
},
set(value) {
if (values === 'single' && Array.isArray(value)) {
if (!values.includes('array') && !values.includes('list') && Array.isArray(value)) {
throw new Error(`${name}: Cannot set array to a non-array property`);

@@ -153,3 +159,3 @@ }

});
if (values === 'list') {
if (values.includes('list')) {
if (termsArray.length === 0) {

@@ -156,0 +162,0 @@ subject.addOut(lastPredicate, rdf_ns_builders_1.rdf.nil);

{
"name": "@tpluscode/rdfine",
"version": "0.4.23",
"version": "0.4.24",
"description": "RDF/JS idiomatic, native, effective",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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