Socket
Socket
Sign inDemoInstall

@ospin/fct-graph

Package Overview
Dependencies
11
Maintainers
4
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.24.1 to 2.25.0

src/fctGraph/Utils/predicates/fctsAreFunctionallyEqual.js

2

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

const Joi = require('joi')
const ArrayUtils = require('@choux/array-utils')

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

static get _NON_TEMPLATE_KEYS() {
return [ 'id', 'name' ]
}
get isPhysical() { return !this.isVirtual }

@@ -86,2 +91,4 @@

isVirtual = false,
ports = [],
firmwareBlackBox = {},
slots: slotsData,

@@ -93,2 +100,4 @@ }) {

this.isVirtual = isVirtual
this.ports = ports
this.firmwareBlackBox = firmwareBlackBox
this.slots = []

@@ -106,2 +115,4 @@

isVirtual: this.isVirtual,
ports: this.ports,
firmwareBlackBox: this.firmwareBlackBox,
slots: this.slots.map(slot => slot.serialize()),

@@ -111,2 +122,16 @@ }

serializeToTemplate() {
const serializedFctTemplate = ObjUtils.exclude(
this.serialize(),
this.constructor._NON_TEMPLATE_KEYS,
)
const slotTemplates = this.slots.map(slot => slot.serializeToTemplate())
const sortedSlotTemplates = ArrayUtils.sortObjectsByKeyValue(slotTemplates, 'name')
serializedFctTemplate.slots = sortedSlotTemplates
return ObjUtils.sortByKeys(serializedFctTemplate)
}
slotTypes() {

@@ -215,2 +240,9 @@ return this.slots.map(({ type }) => type)

isFunctionallyEqualTo(otherFct) {
const thisFctTemplate = this.serializeToTemplate()
const otherFctTemplate = otherFct.serializeToTemplate()
return ObjUtils.objsDeepEqual(thisFctTemplate, otherFctTemplate)
}
disconnectAll() { this.slots.forEach(slot => slot.disconnectAll()) }

@@ -217,0 +249,0 @@

@@ -24,2 +24,4 @@ const faker = require('faker')

isVirtual: faker.datatype.boolean(),
ports: [],
firmwareBlackBox: {},
...data,

@@ -26,0 +28,0 @@ }

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

const DataStream = require('../dataStreams/DataStream')
const ObjUtils = require('../utils/ObjUtils')
const { publicSuccessRes, publicErrorRes } = require('../utils/publicResponses')

@@ -101,2 +102,6 @@ const SlotConnectionError = require('./SlotConnectionError')

static get _NON_TEMPLATE_KEYS() {
return [ 'dataStreams' ]
}
constructor({

@@ -128,2 +133,11 @@ name,

serializeToTemplate() {
const serializedSlotTemplate = ObjUtils.exclude(
this.serialize(),
this.constructor._NON_TEMPLATE_KEYS,
)
return serializedSlotTemplate
}
assertStructure() {

@@ -130,0 +144,0 @@ // Virtual

@@ -27,2 +27,13 @@ const diff = require('deep-diff')

// removes props (keys)
const exclude = (obj, keys) => {
const newObj = { ...obj }
keys.forEach(key => {
delete newObj[key]
})
return newObj
}
module.exports = {

@@ -32,2 +43,3 @@ sortByKeys,

objsDeepEqual,
exclude,
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc