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.22.0 to 2.23.0

src/fctGraph/Utils/predicates/fctGraphsAreSameWithoutIONodes.js

2

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

@@ -196,3 +196,3 @@ [![codecov](https://codecov.io/gh/ospin-web-dev/FCTGraph/branch/main/graph/badge.svg?token=RXXLX0HDAR)](https://codecov.io/gh/ospin-web-dev/FCTGraph)

The FCTGraph has a pretty big appetite for specific and involved mutation methods and queries. To accommodate this, while avoiding class bloat, there exist FCTGraph Utils. The Utils are a collecting place for mutators, queries, and anything else related that is not considered 'core' enough functionality to exist on the classes directly.
The FCTGraph has a pretty big appetite for specific and involved mutation methods and queries. To accommodate this, while avoiding class bloat, there exist FCTGraph Utils. The Utils are a collecting place for mutators, predicates, and anything else related that is not considered 'core' enough functionality to exist on the classes directly.

@@ -204,3 +204,3 @@ ```js

mutators: { addPushOutFctForAllOutSlotsWhichHaveNone },
queries,
predicates: { fctGraphsAreSameWithoutIONodes },
}

@@ -207,0 +207,0 @@ } = require('@ospin/fct-graph')

@@ -174,2 +174,6 @@ const Joi = require('joi')

getIONodeFcts() {
return [...this.getInputFcts(), ...this.getOutputFcts()]
}
getOutputFctsByDestinationName(destinationName) {

@@ -204,4 +208,38 @@ return this.getOutputFcts().filter(({ destination: { name } }) => name === destinationName)

fctsDeepEquals(fctGraphB) {
if (this.functionalities.length !== fctGraphB.functionalities.length) {
return false
}
const sortedFctGraphs = [this.clone(), fctGraphB.clone()].map(fctGraph => {
const sortedFcts = ArrayUtils.sortObjectsByKeyValue(fctGraph.functionalities, 'id')
const fctsWithSortedSlots = sortedFcts.map(fct => {
fct.slots = ArrayUtils.sortObjectsByKeyValue(fct.slots, 'name') //eslint-disable-line
return fct
})
return fctsWithSortedSlots
})
return !sortedFctGraphs[0].some((fct, index) => !fct.isDeepEqual(sortedFctGraphs[1][index]))
}
disconnectAll() { this.functionalities.forEach(fct => fct.disconnectAll()) }
_removeFct(fctToBeRemoved) {
fctToBeRemoved.disconnectAll()
const fctIndex = this.functionalities.findIndex(fct => fct.id === fctToBeRemoved.id)
if (fctIndex === -1) {
throw Error('Fct can not be found on the graph')
}
this.functionalities.splice(fctIndex, 1)
return publicSuccessRes({ removedFct: fctToBeRemoved })
}
removeFct(fct) {
try {
return this._removeFct(fct)
} catch (e) {
return publicErrorRes({ errorMsg: e.message, functionality: fct })
}
}
}

@@ -208,0 +246,0 @@

@@ -13,5 +13,7 @@ /* fctGraphUtils is a collecting place for single purpose specialty

const mutators = require('./mutators')
const predicates = require('./predicates')
module.exports = {
mutators,
predicates,
}
const Joi = require('joi')
const RegexUtils = require('../utils/RegexUtils')
const ObjUtils = require('../utils/ObjUtils')
const InSlot = require('../slots/InSlot')

@@ -9,2 +10,3 @@ const OutSlot = require('../slots/OutSlot')

const SetProtectedPropertyError = require('./FCTErrors/SetProtectedPropertyError')
const ArrayUtils = require('@choux/array-utils')

@@ -204,2 +206,6 @@ class Functionality {

isDeepEqual(fct) {
return ObjUtils.objsDeepEqual(this.serialize(), fct.serialize())
}
isSubType(subType) { return this.subType === subType }

@@ -206,0 +212,0 @@

@@ -28,11 +28,6 @@ const util = require('util')

static diff(objA, objB) {
return diff(objA, objB) // library returns undefined for no diffs
static deepEquals(instanceA, instanceB) {
return ObjUtils.objsDeepEqual(instanceA.serialize(), instanceB.serialize())
}
static deepEquals(objA, objB) {
const objDiff = this.diff(objA.serialize(), objB.serialize())
return typeof objDiff === 'undefined'
}
static enrichJoiValidationError(error) {

@@ -54,3 +49,8 @@ // eslint-disable-next-line

serialize(data) {
clone() {
const data = this.serialize()
return new this.constructor(data)
}
serialize() {
// This super looks backwards because JOIous is composed in to classes

@@ -61,3 +61,3 @@ // in this case it anonymously extends the base class it is composed in to

}
return super.serialize(data)
return super.serialize()
}

@@ -64,0 +64,0 @@

@@ -0,1 +1,2 @@

const diff = require('deep-diff')
/* eslint-disable no-return-assign */

@@ -19,2 +20,13 @@ /* eslint-disable no-sequences */

module.exports = { sortByKeys }
const objsDeepDiff = (objA, objB) => diff(objA, objB) // library returns undefined for no diffs
const objsDeepEqual = (objA, objB) => {
const objDiff = objsDeepDiff(objA, objB)
return typeof objDiff === 'undefined'
}
module.exports = {
sortByKeys,
objsDeepDiff,
objsDeepEqual,
}
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