Skip to content

Commit

Permalink
LLink ES6 class conversion (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: filtered <[email protected]>
  • Loading branch information
huchenlei and webfiltered authored Aug 9, 2024
1 parent b0bcb0e commit f00b6b1
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/litegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2229,46 +2229,46 @@ const globalExport = {};
globalThis.LGraph = LiteGraph.LGraph = LGraph;

//this is the class in charge of storing link information
function LLink(id, type, origin_id, origin_slot, target_id, target_slot) {
this.id = id;
this.type = type;
this.origin_id = origin_id;
this.origin_slot = origin_slot;
this.target_id = target_id;
this.target_slot = target_slot;

this._data = null;
this._pos = new Float32Array(2); //center
}

LLink.prototype.configure = function(o) {
if (o.constructor === Array) {
this.id = o[0];
this.origin_id = o[1];
this.origin_slot = o[2];
this.target_id = o[3];
this.target_slot = o[4];
this.type = o[5];
} else {
this.id = o.id;
this.type = o.type;
this.origin_id = o.origin_id;
this.origin_slot = o.origin_slot;
this.target_id = o.target_id;
this.target_slot = o.target_slot;
class LLink {
constructor(id, type, origin_id, origin_slot, target_id, target_slot) {
this.id = id;
this.type = type;
this.origin_id = origin_id;
this.origin_slot = origin_slot;
this.target_id = target_id;
this.target_slot = target_slot;

this._data = null;
this._pos = new Float32Array(2); //center
}
configure(o) {
if (o.constructor === Array) {
this.id = o[0];
this.origin_id = o[1];
this.origin_slot = o[2];
this.target_id = o[3];
this.target_slot = o[4];
this.type = o[5];
} else {
this.id = o.id;
this.type = o.type;
this.origin_id = o.origin_id;
this.origin_slot = o.origin_slot;
this.target_id = o.target_id;
this.target_slot = o.target_slot;
}
}
};

LLink.prototype.serialize = function() {
return [
this.id,
this.origin_id,
this.origin_slot,
this.target_id,
this.target_slot,
this.type
];
};
serialize() {
return [
this.id,
this.origin_id,
this.origin_slot,
this.target_id,
this.target_slot,
this.type
];
}
}

LiteGraph.LLink = LLink;

Expand Down

0 comments on commit f00b6b1

Please sign in to comment.