Skip to content

Commit

Permalink
.nodes is now .objects, removes graph.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Feb 2, 2024
1 parent bec1bba commit 9ac7bba
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 243 deletions.
144 changes: 0 additions & 144 deletions modules/graph-OLD.js

This file was deleted.

48 changes: 0 additions & 48 deletions modules/graph.js

This file was deleted.

12 changes: 4 additions & 8 deletions modules/graph/connectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ const assign = Object.assign;
const define = Object.defineProperties;


function getNodeFrom(nodes, src) {
function getObjectFrom(objects, src) {
return typeof src === 'object' ?
nodes.find((entry) => entry === src || entry.node === src) :
nodes.find(matches({ id: src })) ;
}

function create() {

objects.find((object) => object === src || object.node === src) :
objects.find(matches({ id: src })) ;
}


Expand Down Expand Up @@ -61,7 +57,7 @@ assign(Connectors.prototype, {
const privates = Privates(this);
let n = -1;
while (this[++n]);
return this[n] = new Connector(this, getNodeFrom(privates.nodes, src), getNodeFrom(privates.nodes, tgt), srcChan, tgtChan);
return this[n] = new Connector(this, getObjectFrom(privates.nodes, src), getObjectFrom(privates.nodes, tgt), srcChan, tgtChan);
}
}),

Expand Down
14 changes: 7 additions & 7 deletions modules/graph/nodes.js → modules/graph/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { log } from '../print.js';


/**
GraphNodes()
Objects()
**/

const assign = Object.assign;
Expand All @@ -29,7 +29,7 @@ const properties = {
}
};

export default function GraphNodes(stage, data = [], context, merger, transport) {
export default function Objects(stage, data = [], context, merger, transport) {
// Objects that should be passed onto child nodes
const privates = Privates(this);
privates.stage = stage;
Expand All @@ -44,20 +44,20 @@ export default function GraphNodes(stage, data = [], context, merger, transport)
// Loop through nodes in data and create entries for them
let n = -1, d;
while (d = data[++n]) this.create(d.type, d.id, d.node, d.events, context, merger, transport);
log('GraphNodes', data.length + ' nodes');
log('Objects', data.length + ' nodes');
}

assign(GraphNodes, {
assign(Objects, {
/*from: function(data) {
return new GraphNodes(data.stage, data.nodes, data.context, data.merger, data.transport);
return new Objects(data.stage, data.nodes, data.context, data.merger, data.transport);
},*/

types: {
default: GraphNode
}
});

define(GraphNodes.prototype, {
define(Objects.prototype, {
length: {
get: function() {
let n = -1;
Expand All @@ -67,7 +67,7 @@ define(GraphNodes.prototype, {
}
});

assign(GraphNodes.prototype, {
assign(Objects.prototype, {
create: overload((object) => typeof object, {
object: function(data) {
const privates = Privates(this);
Expand Down
Loading

0 comments on commit 9ac7bba

Please sign in to comment.