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

@ospin/fct-graph

Package Overview
Dependencies
Maintainers
4
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ospin/fct-graph - npm Package Compare versions

Comparing version 2.14.0 to 2.15.0

src/fctGraph/Utils/mutators/addIntervalOutFctForAllOutSlotsWhichHaveNone.js

2

package.json
{
"name": "@ospin/fct-graph",
"author": "danielseehausen",
"version": "2.14.0",
"version": "2.15.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",

@@ -9,2 +9,3 @@ const Joi = require('joi')

const PushOut = require('../functionalities/PushOut')
const IntervalOut = require('../functionalities/IntervalOut')
const PushIn = require('../functionalities/PushIn')

@@ -153,2 +154,6 @@ const RegexUtils = require('../utils/RegexUtils')

getIntervalOutFcts() {
return this.getOutputFcts().filter(({ subType }) => subType === IntervalOut.SUB_TYPE)
}
getFctById(fctId) {

@@ -155,0 +160,0 @@ return this.functionalities.find(({ id }) => id === fctId)

const assertFCTGraphFirstArgument = require('../helpers/assertFCTGraphFirstArgument')
const addPushOutFctForOutSlotWhichHasNone = require('./addPushOutFctForOutSlotWhichHasNone')
const addOutputFctForAllOutSlotsWhichHaveNone = require('./addOutputFctForAllOutSlotsWhichHaveNone')
function isValidSlot(slot) {
return (
slot.isEmpty
&& slot.isOutSlot
&& !slot.isConnectedToOutputNode
)
}
function addPushOutFctForAllOutSlotsWhichHaveNone(fctGraph) {
fctGraph.functionalities.forEach(({ slots }) => {
slots.forEach(slot => {
if (isValidSlot(slot)) {
addPushOutFctForOutSlotWhichHasNone(fctGraph, slot)
}
})
})
addOutputFctForAllOutSlotsWhichHaveNone(fctGraph, addPushOutFctForOutSlotWhichHasNone)
}

@@ -21,0 +8,0 @@

@@ -1,41 +0,5 @@

const { v4: uuidv4 } = require('uuid')
const assertFCTGraphFirstArgument = require('../helpers/assertFCTGraphFirstArgument')
const addOutputFctForOutSlotWhichHasNone = require('./addOutputFctForOutSlotWhichHasNone')
const PushOut = require('../../../functionalities/PushOut')
const InSlot = require('../../../slots/InSlot')
const OutSlot = require('../../../slots/OutSlot')
function assertIsOutSlot(slot) {
if (!(slot instanceof OutSlot)) {
throw new Error(`${slot} must be of type ${OutSlot.TYPE}`)
}
}
function assertSlotsFctExists(slot) {
const slotsParentFctExists = !!slot.functionality
if (!slotsParentFctExists) {
throw new Error(`${slot} parent fct can not be found by in the fctGraph`)
}
}
function assertDoesNotHaveConnectedOutputNode(slot) {
if (slot.isConnectedToOutputNode) {
throw new Error(`${slot} already has a connected OutputNode`)
}
}
function assertPrerequisites(fctGraph, outSlot) {
assertIsOutSlot(outSlot)
assertSlotsFctExists(outSlot)
assertDoesNotHaveConnectedOutputNode(outSlot)
}
function safeAddPushOutAndConnect(fctGraph, outSlot, pushOutFct) {
fctGraph.addFunctionality(pushOutFct)
const addConnectionResponse = outSlot.connectTo(pushOutFct.inSlots[0])
return addConnectionResponse
}
const DEFAULT_OPTS = {

@@ -46,24 +10,3 @@ pushOutData: {},

function addPushOutFctForOutSlotWhichHasNone(fctGraph, outSlot, opts = DEFAULT_OPTS) {
assertPrerequisites(fctGraph, outSlot)
const functionalityId = uuidv4()
const inSlotData = {
type: InSlot.TYPE,
dataType: outSlot.dataType,
name: outSlot.name,
functionalityId,
displayType: outSlot.displayType,
unit: outSlot.unit,
dataStreams: [],
}
const pushOutFct = PushOut.newAndAssertStructure({
id: functionalityId,
name: 'Push Out',
...opts.pushOutData,
slots: [ inSlotData ],
})
return safeAddPushOutAndConnect(fctGraph, outSlot, pushOutFct)
return addOutputFctForOutSlotWhichHasNone(fctGraph, outSlot, PushOut, opts)
}

@@ -70,0 +13,0 @@

@@ -22,4 +22,13 @@ const OutputNodeSeeder = require('./OutputNodeSeeder')

static generateFloatIntervalOutCelsius(overrideData) {
return this.generate({
slots: [
FloatInSlotSeeder.generate({ name: 'value in', unit: '°C' }),
],
...overrideData,
})
}
}
module.exports = IntervalOutSeeder
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