@ospin/fct-graph
Advanced tools
Comparing version 2.26.1 to 2.27.0
{ | ||
"name": "@ospin/fct-graph", | ||
"author": "danielseehausen", | ||
"version": "2.26.1", | ||
"version": "2.27.0", | ||
"description": "Graph data structure with conditional edges via 'slots' on nodes. Intended to represent physical and virtual functionalities on a device.", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -233,4 +233,8 @@ const Joi = require('joi') | ||
resolveInterSlotUnit() { | ||
return null | ||
} | ||
} | ||
module.exports = Functionality |
@@ -48,6 +48,15 @@ const Joi = require('joi') | ||
get sourceSlot() { | ||
return super.connectedSlots[0] | ||
} | ||
get isInSlot() { return this.type === InSlot.TYPE } | ||
get derivedUnit() { | ||
const derivedUnit = super.derivedUnit | ||
return derivedUnit || (this.sourceSlot && this.sourceSlot.derivedUnit) || this.unit | ||
} | ||
} | ||
module.exports = InSlot |
@@ -56,2 +56,7 @@ const Joi = require('joi') | ||
get derivedUnit() { | ||
const derivedUnit = super.derivedUnit | ||
return derivedUnit || this.unit | ||
} | ||
_assertHasRoomForConnectionTo() { // eslint-disable-line | ||
@@ -58,0 +63,0 @@ // outslots are currently unlimited in the dataStreams they send out |
@@ -16,26 +16,6 @@ const Joi = require('joi') | ||
* **************************************************************** */ | ||
static get UNIT_TYPES() { | ||
return { | ||
TEMPERATURE: 'temperature', | ||
ROTATIONAL_SPEED: 'rotationalSpeed', | ||
PERCENTAGE: 'percentage', | ||
UNITLESS: 'unitless', | ||
} | ||
} | ||
static get ANY_UNIT_STRING() { return 'any' } | ||
static get UNIT_TYPE_UNIT_OPTIONS() { | ||
return { | ||
[Slot.UNIT_TYPES.TEMPERATURE]: ['K', '°C', '°F'], | ||
[Slot.UNIT_TYPES.ROTATIONAL_SPEED]: ['rpm'], | ||
[Slot.UNIT_TYPES.PERCENTAGE]: ['%'], | ||
[Slot.UNIT_TYPES.UNITLESS]: ['-'], | ||
} | ||
} | ||
static get UNITLESS_UNIT() { return '-' } | ||
static get UNITLESS_UNIT() { return Slot.UNIT_TYPE_UNIT_OPTIONS[Slot.UNIT_TYPES.UNITLESS][0] } | ||
static get ALL_UNIT_VALUES() { | ||
return Object.values(this.UNIT_TYPE_UNIT_OPTIONS) | ||
.reduce((acc, opts) => ([ ...acc, ...opts ]), []) | ||
} | ||
/* **************************************************************** */ | ||
@@ -52,2 +32,4 @@ | ||
slotA.unit !== slotB.unit | ||
&& slotA.unit !== Slot.ANY_UNIT_STRING | ||
&& slotB.unit !== Slot.ANY_UNIT_STRING | ||
) { | ||
@@ -99,3 +81,3 @@ throw new SlotConnectionError(slotA, slotB, 'units must match between slots') | ||
dataStreams: Joi.array().items(DataStream.SCHEMA).required(), | ||
unit: Joi.string().allow(...this.ALL_UNIT_VALUES).required(), | ||
unit: Joi.string().required(), | ||
}) | ||
@@ -123,2 +105,8 @@ } | ||
get derivedUnit() { | ||
return this.unit === Slot.ANY_UNIT_STRING | ||
? this.functionality.resolveInterSlotUnit(this) | ||
: this.unit | ||
} | ||
get isEmpty() { return this.dataStreams.length === 0 } | ||
@@ -125,0 +113,0 @@ |
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
3084
149264