@ejfdelgado/ejflab-common 1.10.1 → 1.10.3

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.10.1",
4
+ "version": "1.10.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
@@ -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
- } else {
14
- timeline.t = timeline.t + timeline.period;
15
- if (timeline.t > timeline.end) {
16
- timeline.t = timeline.end;
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 == null) {
86
- console.log(`${sourcePair} doesn't match ^(in|out)\.(b\.([^.]+)\.([^.]+)|d\.(.+))$`);
87
- return false;
88
- }
89
- if (partsSource[1] == "in") {
90
- // It's an input
91
- const buffer = this.readInputFrom(!partsSource[5], partsSource[3], partsSource[4], partsSource[5]);
92
- if (buffer === undefined) {
93
- return false;
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
- // Its an output
98
- outputs.push(partsSource[2]);
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
- namedInputs[key] = buffer;
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