graphai 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle.cjs.js +1 -1
- package/lib/bundle.cjs.js.map +1 -1
- package/lib/bundle.esm.js +27 -2
- package/lib/bundle.esm.js.map +1 -1
- package/lib/bundle.umd.js +1 -1
- package/lib/bundle.umd.js.map +1 -1
- package/lib/graphai.d.ts +2 -1
- package/lib/graphai.js +5 -0
- package/lib/utils/prop_function.js +22 -2
- package/package.json +6 -6
package/lib/bundle.esm.js
CHANGED
|
@@ -76,6 +76,18 @@ const propArrayFunction = (result, propId) => {
|
|
|
76
76
|
if (propId === "isEmpty()") {
|
|
77
77
|
return result.length === 0;
|
|
78
78
|
}
|
|
79
|
+
if (propId === "average()" || propId === "mean()") {
|
|
80
|
+
return result.length ? result.reduce((a, b) => a + b, 0) / result.length : 0;
|
|
81
|
+
}
|
|
82
|
+
if (propId === "sum()") {
|
|
83
|
+
return result.reduce((a, b) => a + b, 0);
|
|
84
|
+
}
|
|
85
|
+
if (propId === "max()") {
|
|
86
|
+
return result.length ? Math.max(...result) : 0;
|
|
87
|
+
}
|
|
88
|
+
if (propId === "min()") {
|
|
89
|
+
return result.length ? Math.min(...result) : 0;
|
|
90
|
+
}
|
|
79
91
|
// array join
|
|
80
92
|
const matchJoin = propId.match(/^join\(([,-\s]?)\)$/);
|
|
81
93
|
if (matchJoin && Array.isArray(matchJoin)) {
|
|
@@ -101,13 +113,13 @@ const propObjectFunction = (result, propId) => {
|
|
|
101
113
|
const propStringFunction = (result, propId) => {
|
|
102
114
|
if (typeof result === "string") {
|
|
103
115
|
if (propId === "codeBlock()") {
|
|
104
|
-
const match = ("\n" + result).match(/\n```[a-zA-
|
|
116
|
+
const match = ("\n" + result).match(/\n```[a-zA-Z]*([\s\S]*?)\n```/);
|
|
105
117
|
if (match) {
|
|
106
118
|
return match[1];
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
121
|
if (propId === "codeBlockOrRaw()") {
|
|
110
|
-
const match = ("\n" + result).match(/\n```[a-zA-
|
|
122
|
+
const match = ("\n" + result).match(/\n```[a-zA-Z]*([\s\S]*?)\n```/);
|
|
111
123
|
if (match) {
|
|
112
124
|
return match[1];
|
|
113
125
|
}
|
|
@@ -131,6 +143,10 @@ const propStringFunction = (result, propId) => {
|
|
|
131
143
|
if (propId === "toUpperCase()") {
|
|
132
144
|
return result.toUpperCase();
|
|
133
145
|
}
|
|
146
|
+
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-./:;<=>?@]+)\)/);
|
|
147
|
+
if (equalMatch) {
|
|
148
|
+
return result === equalMatch[1];
|
|
149
|
+
}
|
|
134
150
|
const sliceMatch = propId.match(/^slice\((-?\d+)(?:,\s*(-?\d+))?\)/);
|
|
135
151
|
if (sliceMatch) {
|
|
136
152
|
if (sliceMatch[2] !== undefined) {
|
|
@@ -158,6 +174,10 @@ const propNumberFunction = (result, propId) => {
|
|
|
158
174
|
if (match) {
|
|
159
175
|
return Number(result) + Number(match[1]);
|
|
160
176
|
}
|
|
177
|
+
const equalMatch = propId.match(/^equal\(([A-Za-z0-9!#$%&()*+,\-./:;<=>?@]+)\)/);
|
|
178
|
+
if (equalMatch) {
|
|
179
|
+
return result === Number(equalMatch[1]);
|
|
180
|
+
}
|
|
161
181
|
}
|
|
162
182
|
return undefined;
|
|
163
183
|
};
|
|
@@ -1576,6 +1596,11 @@ class GraphAI {
|
|
|
1576
1596
|
this.staticNodeInitData[nodeId] = value;
|
|
1577
1597
|
this.updateStaticNodeValue(nodeId, value, injectFrom);
|
|
1578
1598
|
}
|
|
1599
|
+
setLoopCount(count) {
|
|
1600
|
+
this.loop = {
|
|
1601
|
+
count,
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1579
1604
|
updateStaticNodeValue(nodeId, value, injectFrom) {
|
|
1580
1605
|
const node = this.nodes[nodeId];
|
|
1581
1606
|
if (node && node.isStaticNode) {
|