-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbstractNode.js
More file actions
57 lines (57 loc) · 1.85 KB
/
Copy pathAbstractNode.js
File metadata and controls
57 lines (57 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractNode = void 0;
class AbstractNode {
// TODO: 4 Decide whether "config" in AbstractNode should be a class member or not. "config" *is* a class
// member in all derived classes, but can have a different type there. What is the best/correct solution here?
constructor(config, RED) {
this.RED = RED;
RED.nodes.createNode(this, config);
}
//########### END Log methods ##########
//################# BEGIN properties to access context ################
// https://nodered.org/docs/creating-nodes/context
getNodeContext() {
return this.context();
}
getFlowContext() {
return this.context().flow;
}
getGlobalContext() {
return this.context().global;
}
//################# END properties to access context ################
// TODO: 3 Define 'AbstractNode' type for the result array here?
getNextNodes() {
let result = [];
this.RED.nodes.eachNode((node) => {
// TODO: 3 Finish this
for (let wire of this.wires) {
for (let id of wire) {
if (id == node.id) {
result.push(node);
}
}
}
});
return result;
}
// TODO: 3 Define 'AbstractNode' type for the result array here?
getPrevNodes() {
let result = [];
this.RED.nodes.eachNode((node) => {
if (node.wires == undefined) {
return;
}
for (let wire of node.wires) {
for (let id of wire) {
if (id == this.id) {
result.push(node);
}
}
}
});
return result;
}
}
exports.AbstractNode = AbstractNode;