@ejfdelgado/ejflab-common 1.10.1 → 1.10.4
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/package.json
CHANGED
package/src/MyTemplate.js
CHANGED
|
@@ -213,6 +213,18 @@ class MyTemplate extends CsvWithFilters {
|
|
|
213
213
|
}
|
|
214
214
|
replaceBareValues(template, data, open = "\\{", close = "\\}", closeNoScape = "}", useStringify = false, skipUndefined = false) {
|
|
215
215
|
const myPattern = new RegExp("\\$\\s*" + open + "([^" + closeNoScape + "]+)\\s*" + close, "g");
|
|
216
|
+
// Segond level replace
|
|
217
|
+
const myPattern2d = new RegExp("(\\$\\s*" + open + "[^$" + closeNoScape + "]+)\\$" + open + "([^" + closeNoScape + "]+)" + close + "([^" + closeNoScape + "]*" + close + ")", "g");
|
|
218
|
+
template = template.replace(myPattern2d, (match, g1, g2, g3) => {
|
|
219
|
+
const response = this.getColumnDescription(g2)[0];
|
|
220
|
+
const valor = SimpleObj.getValue(data, response.id);
|
|
221
|
+
const temp = this.filterValue(valor, response, undefined, response.id);
|
|
222
|
+
if (temp === undefined) {
|
|
223
|
+
return match;
|
|
224
|
+
} else {
|
|
225
|
+
return g1 + temp + g3;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
216
228
|
template = template.replace(myPattern, (match, g1) => {
|
|
217
229
|
const response = this.getColumnDescription(g1)[0];
|
|
218
230
|
const valor = SimpleObj.getValue(data, response.id);
|
package/src/MyTemplate.test.js
CHANGED
|
@@ -76,6 +76,18 @@ function myTest() {
|
|
|
76
76
|
exp: "my name is undefined Delgado and I like undefined undefined",
|
|
77
77
|
skipUndefined: false,
|
|
78
78
|
},
|
|
79
|
+
{
|
|
80
|
+
txt: "My ${index} lastname is ${lastname.${index}}",
|
|
81
|
+
data: { lastname: ["delgado", "leyton"], index: 0 },
|
|
82
|
+
exp: "My 0 lastname is delgado",
|
|
83
|
+
skipUndefined: false,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
txt: "My ${index} lastname is ${lastname.${index}.detail}",
|
|
87
|
+
data: { lastname: [{ detail: "delgado" }, { detail: "leyton" }], index: 0 },
|
|
88
|
+
exp: "My 0 lastname is delgado",
|
|
89
|
+
skipUndefined: false,
|
|
90
|
+
},
|
|
79
91
|
];
|
|
80
92
|
|
|
81
93
|
renderer.registerFunction("json", CsvFormatterFilters.json);
|
|
@@ -7,11 +7,14 @@ class CommandTimeline extends CommandBasic {
|
|
|
7
7
|
const start = parseFloat(this.args[1]);
|
|
8
8
|
const end = parseFloat(this.args[2]);
|
|
9
9
|
const period = parseFloat(this.args[3]);
|
|
10
|
+
const n = parseFloat(this.args[4]);
|
|
10
11
|
const timeline = {
|
|
11
12
|
start,
|
|
12
13
|
end,
|
|
13
14
|
period,
|
|
15
|
+
n
|
|
14
16
|
};
|
|
17
|
+
//console.log(`Timeline ${JSON.stringify(timeline)}`);
|
|
15
18
|
this.context.registerTimeline(timeLineId, timeline);
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -10,12 +10,24 @@ class CommandTimelineNext extends CommandBasic {
|
|
|
10
10
|
}
|
|
11
11
|
if ([null, undefined].indexOf(timeline.t) >= 0) {
|
|
12
12
|
timeline.t = timeline.start;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
}
|
|
14
|
+
// Always start from the period and expect to read backwards
|
|
15
|
+
timeline.t = timeline.t + timeline.period;
|
|
16
|
+
if (timeline.t > timeline.end) {
|
|
17
|
+
timeline.t = timeline.end;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Check if should create N array
|
|
21
|
+
if (typeof timeline.n == "number" && timeline.n > 0) {
|
|
22
|
+
const dperiod = timeline.period / timeline.n;
|
|
23
|
+
const list = new Array(timeline.n);
|
|
24
|
+
for (let i=0; i<list.length; i++) {
|
|
25
|
+
list[i] = {done: false};
|
|
17
26
|
}
|
|
27
|
+
timeline.dperiod = dperiod;
|
|
28
|
+
timeline.list = list;
|
|
18
29
|
}
|
|
30
|
+
|
|
19
31
|
// Compute advance percentage
|
|
20
32
|
const percentage = (timeline.t - timeline.start) / (timeline.end - timeline.start);
|
|
21
33
|
SimpleObj.recreate(this.context.data, `scope.progressEach.${timeLineId}`, Math.ceil(percentage * 100));
|
|
@@ -82,23 +82,26 @@ class StepProcess extends StepBasic {
|
|
|
82
82
|
for (let i = 1; i < this.args.length; i++) {
|
|
83
83
|
const sourcePair = this.args[i];
|
|
84
84
|
const partsSource = /^(in|out):(b\.([^.]+)\.([^.]+)|d\.(.+))$/i.exec(sourcePair);
|
|
85
|
-
if (partsSource
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
if (partsSource !== null) {
|
|
86
|
+
if (partsSource[1] == "in") {
|
|
87
|
+
// It's an input
|
|
88
|
+
const buffer = this.readInputFrom(!partsSource[5], partsSource[3], partsSource[4], partsSource[5]);
|
|
89
|
+
if (buffer === undefined) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
inputs.push(buffer);
|
|
93
|
+
} else {
|
|
94
|
+
// Its an output
|
|
95
|
+
outputs.push(partsSource[2]);
|
|
94
96
|
}
|
|
95
|
-
inputs.push(buffer);
|
|
96
97
|
} else {
|
|
97
|
-
//
|
|
98
|
-
|
|
98
|
+
// Place the raw input
|
|
99
|
+
inputs.push(sourcePair);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
const currentIndex = inputs[0];
|
|
104
|
+
const useIndexedN = (typeof currentIndex == "number");
|
|
102
105
|
const namedInputs = {};
|
|
103
106
|
if (!!inputConnectionsConf) {
|
|
104
107
|
for (let i = 0; i < inputConnectionsConf.length; i++) {
|
|
@@ -107,7 +110,12 @@ class StepProcess extends StepBasic {
|
|
|
107
110
|
if (buffer === undefined) {
|
|
108
111
|
return false;
|
|
109
112
|
}
|
|
110
|
-
|
|
113
|
+
if (useIndexedN && buffer instanceof Array) {
|
|
114
|
+
// Connect the indexed part of the array, even if it is undefined
|
|
115
|
+
namedInputs[key] = buffer[currentIndex];
|
|
116
|
+
} else {
|
|
117
|
+
namedInputs[key] = buffer;
|
|
118
|
+
}
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
121
|
|