@hpcc-js/dataflow 9.5.0 → 9.5.1
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/dist/index.js +478 -417
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,500 +1,561 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
3
|
function isSource(source) {
|
|
3
|
-
|
|
4
|
+
return source && (typeof source[Symbol.iterator] === "function" || Array.isArray(source));
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/activities/concat.ts
|
|
6
|
+
__name(isSource, "isSource");
|
|
8
7
|
function concatGen(concatSource) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
return function* (source) {
|
|
9
|
+
yield* source;
|
|
10
|
+
yield* concatSource;
|
|
11
|
+
};
|
|
13
12
|
}
|
|
13
|
+
__name(concatGen, "concatGen");
|
|
14
14
|
function concat(s_or_n, concatSource) {
|
|
15
|
-
|
|
15
|
+
return concatSource !== void 0 ? concatGen(concatSource)(s_or_n) : concatGen(s_or_n);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/activities/each.ts
|
|
17
|
+
__name(concat, "concat");
|
|
20
18
|
function eachGen(callbackFn) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
19
|
+
return function* (source) {
|
|
20
|
+
let i = -1;
|
|
21
|
+
for (const item of source) {
|
|
22
|
+
callbackFn(item, ++i);
|
|
23
|
+
yield item;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
__name(eachGen, "eachGen");
|
|
29
28
|
function each(s_or_cb, callbackFn) {
|
|
30
|
-
|
|
29
|
+
return isSource(s_or_cb) ? eachGen(callbackFn)(s_or_cb) : eachGen(s_or_cb);
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/activities/entries.ts
|
|
31
|
+
__name(each, "each");
|
|
35
32
|
function entriesGen() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
33
|
+
return function* (source) {
|
|
34
|
+
let i = -1;
|
|
35
|
+
for (const item of source) {
|
|
36
|
+
yield [++i, item];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
__name(entriesGen, "entriesGen");
|
|
41
41
|
function entries(source) {
|
|
42
|
-
|
|
42
|
+
return source ? entriesGen()(source) : entriesGen();
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/activities/filter.ts
|
|
44
|
+
__name(entries, "entries");
|
|
47
45
|
function filterGen(callbackFn) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
return function* (source) {
|
|
47
|
+
let i = -1;
|
|
48
|
+
for (const item of source) {
|
|
49
|
+
if (callbackFn(item, ++i)) {
|
|
50
|
+
yield item;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
__name(filterGen, "filterGen");
|
|
53
56
|
function filter(s_or_cb, callbackFn) {
|
|
54
|
-
|
|
57
|
+
return isSource(s_or_cb) ? filterGen(callbackFn)(s_or_cb) : filterGen(s_or_cb);
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/activities/first.ts
|
|
59
|
+
__name(filter, "filter");
|
|
59
60
|
function firstGen(n) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
61
|
+
return function* (source) {
|
|
62
|
+
let i = 0;
|
|
63
|
+
for (const item of source) {
|
|
64
|
+
yield item;
|
|
65
|
+
if (++i >= n) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
__name(firstGen, "firstGen");
|
|
68
72
|
function first(s_or_n, n) {
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
if (!isSource(s_or_n)) return firstGen(s_or_n);
|
|
74
|
+
return firstGen(n)(s_or_n);
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region src/activities/group.ts
|
|
76
|
+
__name(first, "first");
|
|
75
77
|
function groupGen(groupFn) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
78
|
+
return function* (source) {
|
|
79
|
+
let i = -1;
|
|
80
|
+
const group2 = {};
|
|
81
|
+
for (const row of source) {
|
|
82
|
+
const key = groupFn(row, ++i);
|
|
83
|
+
if (!group2[key]) {
|
|
84
|
+
group2[key] = [];
|
|
85
|
+
}
|
|
86
|
+
group2[key].push(row);
|
|
87
|
+
}
|
|
88
|
+
for (const key in group2) {
|
|
89
|
+
yield { key, value: group2[key] };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
__name(groupGen, "groupGen");
|
|
90
94
|
function group(s_or_gbf, groupByFn) {
|
|
91
|
-
|
|
95
|
+
return isSource(s_or_gbf) ? groupGen(groupByFn)(s_or_gbf) : groupGen(s_or_gbf);
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/observers/observer.ts
|
|
97
|
+
__name(group, "group");
|
|
96
98
|
function Accessor(fof, accesor) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
99
|
+
const s = fof();
|
|
100
|
+
return {
|
|
101
|
+
observe: /* @__PURE__ */ __name((_, i) => {
|
|
102
|
+
s.observe(accesor(_, i), i);
|
|
103
|
+
}, "observe"),
|
|
104
|
+
peek: s.peek
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
__name(Accessor, "Accessor");
|
|
105
108
|
function sensor(s) {
|
|
106
|
-
|
|
109
|
+
return each((r, i) => s.observe(r, i));
|
|
107
110
|
}
|
|
111
|
+
__name(sensor, "sensor");
|
|
108
112
|
function activity(s) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
return function* (source) {
|
|
114
|
+
let i = -1;
|
|
115
|
+
for (const row of source) {
|
|
116
|
+
s.observe(row, ++i);
|
|
117
|
+
}
|
|
118
|
+
yield s.peek();
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
__name(activity, "activity");
|
|
115
122
|
function scalar(s) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
return function(source) {
|
|
124
|
+
let i = -1;
|
|
125
|
+
for (const row of source) {
|
|
126
|
+
s.observe(row, ++i);
|
|
127
|
+
}
|
|
128
|
+
return s.peek();
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
__name(scalar, "scalar");
|
|
125
132
|
function _max() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
133
|
+
let max2;
|
|
134
|
+
return {
|
|
135
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
136
|
+
if (idx === 0) {
|
|
137
|
+
max2 = value;
|
|
138
|
+
} else if (max2 < value) {
|
|
139
|
+
max2 = value;
|
|
140
|
+
}
|
|
141
|
+
}, "observe"),
|
|
142
|
+
peek: /* @__PURE__ */ __name(() => max2, "peek")
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
__name(_max, "_max");
|
|
135
146
|
function max(callbackFn) {
|
|
136
|
-
|
|
147
|
+
return callbackFn ? Accessor(_max, callbackFn) : _max();
|
|
137
148
|
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/observers/min.ts
|
|
149
|
+
__name(max, "max");
|
|
141
150
|
function _min() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
+
let min2;
|
|
152
|
+
return {
|
|
153
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
154
|
+
if (idx === 0) {
|
|
155
|
+
min2 = value;
|
|
156
|
+
} else if (min2 > value) {
|
|
157
|
+
min2 = value;
|
|
158
|
+
}
|
|
159
|
+
}, "observe"),
|
|
160
|
+
peek: /* @__PURE__ */ __name(() => min2, "peek")
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
__name(_min, "_min");
|
|
151
164
|
function min(callbackFn) {
|
|
152
|
-
|
|
165
|
+
return callbackFn ? Accessor(_min, callbackFn) : _min();
|
|
153
166
|
}
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region src/observers/extent.ts
|
|
167
|
+
__name(min, "min");
|
|
157
168
|
function _extent() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
169
|
+
const minFO = min();
|
|
170
|
+
const maxFO = max();
|
|
171
|
+
return {
|
|
172
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
173
|
+
minFO.observe(value, idx);
|
|
174
|
+
maxFO.observe(value, idx);
|
|
175
|
+
}, "observe"),
|
|
176
|
+
peek: /* @__PURE__ */ __name(() => [minFO.peek(), maxFO.peek()], "peek")
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
__name(_extent, "_extent");
|
|
168
180
|
function extent(callbackFn) {
|
|
169
|
-
|
|
181
|
+
return callbackFn ? Accessor(_extent, callbackFn) : _extent();
|
|
170
182
|
}
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/activities/histogram.ts
|
|
183
|
+
__name(extent, "extent");
|
|
174
184
|
function isOptionA(_) {
|
|
175
|
-
|
|
185
|
+
return _.buckets !== void 0;
|
|
176
186
|
}
|
|
187
|
+
__name(isOptionA, "isOptionA");
|
|
177
188
|
function histogramGen(callbackFn, options) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
189
|
+
return function* (_source) {
|
|
190
|
+
let min2;
|
|
191
|
+
let bucketSize;
|
|
192
|
+
let source;
|
|
193
|
+
if (isOptionA(options)) {
|
|
194
|
+
source = Array.isArray(_source) ? _source : [..._source];
|
|
195
|
+
const minMax = scalar(extent(callbackFn))(source);
|
|
196
|
+
if (minMax === void 0) {
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
min2 = minMax[0];
|
|
200
|
+
const max2 = minMax[1];
|
|
201
|
+
const buckets = options.buckets;
|
|
202
|
+
bucketSize = (max2 - min2) / buckets;
|
|
203
|
+
} else {
|
|
204
|
+
source = _source;
|
|
205
|
+
min2 = options.min;
|
|
206
|
+
bucketSize = options.range;
|
|
207
|
+
}
|
|
208
|
+
const histogram2 = {};
|
|
209
|
+
let maxBucketID = 0;
|
|
210
|
+
for (const row of source) {
|
|
211
|
+
const value = callbackFn(row);
|
|
212
|
+
const bucketID = Math.floor((value - min2) / bucketSize);
|
|
213
|
+
if (maxBucketID < bucketID) {
|
|
214
|
+
maxBucketID = bucketID;
|
|
215
|
+
}
|
|
216
|
+
if (histogram2[bucketID] === void 0) {
|
|
217
|
+
histogram2[bucketID] = [];
|
|
218
|
+
}
|
|
219
|
+
histogram2[bucketID].push(row);
|
|
220
|
+
}
|
|
221
|
+
const lastBucket = histogram2[maxBucketID];
|
|
222
|
+
const from = min2 + maxBucketID * bucketSize;
|
|
223
|
+
for (let i = 0; i <= maxBucketID; ++i) {
|
|
224
|
+
if (i === maxBucketID - 1 && lastBucket.every((row) => from === callbackFn(row))) {
|
|
225
|
+
yield {
|
|
226
|
+
from: min2 + i * bucketSize,
|
|
227
|
+
to: min2 + (i + 1) * bucketSize,
|
|
228
|
+
value: [...histogram2[i] || [], ...lastBucket]
|
|
229
|
+
};
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
yield {
|
|
233
|
+
from: min2 + i * bucketSize,
|
|
234
|
+
to: min2 + (i + 1) * bucketSize,
|
|
235
|
+
value: histogram2[i] || []
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
__name(histogramGen, "histogramGen");
|
|
223
241
|
function histogram(s_or_hf, hf_or_b, options) {
|
|
224
|
-
|
|
242
|
+
return isSource(s_or_hf) ? histogramGen(hf_or_b, options)(s_or_hf) : histogramGen(s_or_hf, hf_or_b);
|
|
225
243
|
}
|
|
226
|
-
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/activities/join.ts
|
|
244
|
+
__name(histogram, "histogram");
|
|
229
245
|
function joinGen(_sourceU, callbackFn) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
246
|
+
const sourceB = Array.isArray(_sourceU) ? _sourceU[Symbol.iterator]() : _sourceU;
|
|
247
|
+
return function* (sourceT) {
|
|
248
|
+
let i = -1;
|
|
249
|
+
for (const item of sourceT) {
|
|
250
|
+
yield callbackFn(item, sourceB.next().value, ++i);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
__name(joinGen, "joinGen");
|
|
236
255
|
function join(sT_or_sU, sU_or_cb, callbackFn) {
|
|
237
|
-
|
|
256
|
+
return isSource(sU_or_cb) ? joinGen(sU_or_cb, callbackFn)(sT_or_sU) : joinGen(sT_or_sU, sU_or_cb);
|
|
238
257
|
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/activities/map.ts
|
|
258
|
+
__name(join, "join");
|
|
242
259
|
function mapGen(callbackFn) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
260
|
+
return function* (source) {
|
|
261
|
+
let i = -1;
|
|
262
|
+
for (const item of source) {
|
|
263
|
+
yield callbackFn(item, ++i);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
__name(mapGen, "mapGen");
|
|
248
268
|
function map(s_or_cb, callbackFn) {
|
|
249
|
-
|
|
269
|
+
return isSource(s_or_cb) ? mapGen(callbackFn)(s_or_cb) : mapGen(s_or_cb);
|
|
250
270
|
}
|
|
251
|
-
|
|
252
|
-
//#endregion
|
|
253
|
-
//#region src/activities/normalize.ts
|
|
271
|
+
__name(map, "map");
|
|
254
272
|
function normalizeGen() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
273
|
+
const calcExtent = scalar(extent());
|
|
274
|
+
return function* (_source) {
|
|
275
|
+
const source = Array.isArray(_source) ? _source : [..._source];
|
|
276
|
+
const range = calcExtent(source);
|
|
277
|
+
const divisor = range[1] - range[0] || 1;
|
|
278
|
+
const normalizeMap = map((row) => (row - range[0]) / divisor);
|
|
279
|
+
return yield* normalizeMap(source);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
__name(normalizeGen, "normalizeGen");
|
|
263
283
|
function normalize(s_or_undef) {
|
|
264
|
-
|
|
284
|
+
return isSource(s_or_undef) ? normalizeGen()(s_or_undef) : normalizeGen();
|
|
265
285
|
}
|
|
266
|
-
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/activities/skip.ts
|
|
286
|
+
__name(normalize, "normalize");
|
|
269
287
|
function skipGen(n) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
288
|
+
return function* (source) {
|
|
289
|
+
let i = -1;
|
|
290
|
+
for (const item of source) {
|
|
291
|
+
if (++i >= n) {
|
|
292
|
+
yield item;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
__name(skipGen, "skipGen");
|
|
275
298
|
function skip(s_or_n, n) {
|
|
276
|
-
|
|
299
|
+
return isSource(s_or_n) ? skipGen(n)(s_or_n) : skipGen(s_or_n);
|
|
277
300
|
}
|
|
278
|
-
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/activities/sort.ts
|
|
301
|
+
__name(skip, "skip");
|
|
281
302
|
function sortGen(compareFn) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
303
|
+
return function* (source) {
|
|
304
|
+
yield* (Array.isArray(source) ? source : [...source]).sort(compareFn);
|
|
305
|
+
};
|
|
285
306
|
}
|
|
307
|
+
__name(sortGen, "sortGen");
|
|
286
308
|
function sort(s_or_cb, callbackFn) {
|
|
287
|
-
|
|
309
|
+
return isSource(s_or_cb) ? sortGen(callbackFn)(s_or_cb) : sortGen(s_or_cb);
|
|
288
310
|
}
|
|
289
|
-
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/observers/count.ts
|
|
311
|
+
__name(sort, "sort");
|
|
292
312
|
function count() {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
let count2;
|
|
314
|
+
return {
|
|
315
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
316
|
+
if (idx === 0) {
|
|
317
|
+
count2 = 0;
|
|
318
|
+
}
|
|
319
|
+
++count2;
|
|
320
|
+
}, "observe"),
|
|
321
|
+
peek: /* @__PURE__ */ __name(() => count2, "peek")
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
__name(count, "count");
|
|
305
325
|
function _variance() {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
326
|
+
let count2;
|
|
327
|
+
let mean2;
|
|
328
|
+
let sum;
|
|
329
|
+
return {
|
|
330
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
331
|
+
if (idx === 0) {
|
|
332
|
+
count2 = 0;
|
|
333
|
+
mean2 = 0;
|
|
334
|
+
sum = 0;
|
|
335
|
+
}
|
|
336
|
+
const delta = value - mean2;
|
|
337
|
+
mean2 += delta / ++count2;
|
|
338
|
+
sum += delta * (value - mean2);
|
|
339
|
+
}, "observe"),
|
|
340
|
+
peek: /* @__PURE__ */ __name(() => count2 > 1 ? sum / (count2 - 1) : void 0, "peek")
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
__name(_variance, "_variance");
|
|
323
344
|
function variance(callbackFn) {
|
|
324
|
-
|
|
345
|
+
return callbackFn ? Accessor(_variance, callbackFn) : _variance();
|
|
325
346
|
}
|
|
326
|
-
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/observers/deviation.ts
|
|
347
|
+
__name(variance, "variance");
|
|
329
348
|
function _deviation() {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
349
|
+
const v = variance();
|
|
350
|
+
return {
|
|
351
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
352
|
+
v.observe(value, idx);
|
|
353
|
+
}, "observe"),
|
|
354
|
+
peek: /* @__PURE__ */ __name(() => {
|
|
355
|
+
const variance2 = v.peek();
|
|
356
|
+
return variance2 !== void 0 ? Math.sqrt(variance2) : variance2;
|
|
357
|
+
}, "peek")
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
__name(_deviation, "_deviation");
|
|
341
361
|
function deviation(callbackFn) {
|
|
342
|
-
|
|
362
|
+
return callbackFn ? Accessor(_deviation, callbackFn) : _deviation();
|
|
343
363
|
}
|
|
344
|
-
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region src/observers/mean.ts
|
|
364
|
+
__name(deviation, "deviation");
|
|
347
365
|
function _mean() {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
366
|
+
let total;
|
|
367
|
+
let count2;
|
|
368
|
+
return {
|
|
369
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
370
|
+
if (idx === 0) {
|
|
371
|
+
total = value;
|
|
372
|
+
} else {
|
|
373
|
+
total += value;
|
|
374
|
+
}
|
|
375
|
+
count2 = idx;
|
|
376
|
+
}, "observe"),
|
|
377
|
+
peek: /* @__PURE__ */ __name(() => total / (count2 + 1), "peek")
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
__name(_mean, "_mean");
|
|
359
381
|
function mean(callbackFn) {
|
|
360
|
-
|
|
382
|
+
return callbackFn ? Accessor(_mean, callbackFn) : _mean();
|
|
361
383
|
}
|
|
362
|
-
|
|
363
|
-
//#endregion
|
|
364
|
-
//#region src/observers/distribution.ts
|
|
384
|
+
__name(mean, "mean");
|
|
365
385
|
function _distribution() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
386
|
+
const minFO = min();
|
|
387
|
+
const maxFO = max();
|
|
388
|
+
const meanFO = mean();
|
|
389
|
+
const varianceFO = variance();
|
|
390
|
+
return {
|
|
391
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
392
|
+
minFO.observe(value, idx);
|
|
393
|
+
maxFO.observe(value, idx);
|
|
394
|
+
meanFO.observe(value, idx);
|
|
395
|
+
varianceFO.observe(value, idx);
|
|
396
|
+
}, "observe"),
|
|
397
|
+
peek: /* @__PURE__ */ __name(() => {
|
|
398
|
+
const minResult = minFO.peek();
|
|
399
|
+
if (minResult === void 0) return void 0;
|
|
400
|
+
const varianceResult = varianceFO.peek();
|
|
401
|
+
return {
|
|
402
|
+
min: minResult,
|
|
403
|
+
max: maxFO.peek(),
|
|
404
|
+
mean: meanFO.peek(),
|
|
405
|
+
variance: varianceResult,
|
|
406
|
+
deviation: varianceResult !== void 0 ? Math.sqrt(varianceResult) : void 0
|
|
407
|
+
};
|
|
408
|
+
}, "peek")
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
__name(_distribution, "_distribution");
|
|
391
412
|
function distribution(callbackFn) {
|
|
392
|
-
|
|
413
|
+
return callbackFn ? Accessor(_distribution, callbackFn) : _distribution();
|
|
393
414
|
}
|
|
394
|
-
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/observers/median.ts
|
|
415
|
+
__name(distribution, "distribution");
|
|
397
416
|
function _median() {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
417
|
+
let values;
|
|
418
|
+
return {
|
|
419
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
420
|
+
if (idx === 0) {
|
|
421
|
+
values = [];
|
|
422
|
+
}
|
|
423
|
+
values.push(value);
|
|
424
|
+
}, "observe"),
|
|
425
|
+
peek: /* @__PURE__ */ __name(() => {
|
|
426
|
+
const sorted = values.sort((l, r) => l - r);
|
|
427
|
+
const mid = sorted.length / 2;
|
|
428
|
+
if (sorted.length % 2 === 0) {
|
|
429
|
+
return (sorted[mid - 1] + sorted[mid]) / 2;
|
|
430
|
+
} else {
|
|
431
|
+
return sorted[Math.floor(mid)];
|
|
432
|
+
}
|
|
433
|
+
}, "peek")
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
__name(_median, "_median");
|
|
412
437
|
function median(callbackFn) {
|
|
413
|
-
|
|
438
|
+
return callbackFn ? Accessor(_median, callbackFn) : _median();
|
|
414
439
|
}
|
|
415
|
-
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/observers/quartile.ts
|
|
440
|
+
__name(median, "median");
|
|
418
441
|
function _quartile() {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
};
|
|
450
|
-
}
|
|
442
|
+
let values;
|
|
443
|
+
return {
|
|
444
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
445
|
+
if (idx === 0) {
|
|
446
|
+
values = [];
|
|
447
|
+
}
|
|
448
|
+
values.push(value);
|
|
449
|
+
}, "observe"),
|
|
450
|
+
peek: /* @__PURE__ */ __name(() => {
|
|
451
|
+
const sorted = values.sort((l, r) => l - r);
|
|
452
|
+
const mid = sorted.length / 2;
|
|
453
|
+
let medianVal;
|
|
454
|
+
let lower;
|
|
455
|
+
let upper;
|
|
456
|
+
if (sorted.length < 2) {
|
|
457
|
+
return void 0;
|
|
458
|
+
} else if (sorted.length % 2 === 0) {
|
|
459
|
+
medianVal = (sorted[mid - 1] + sorted[mid]) / 2;
|
|
460
|
+
lower = sorted.slice(0, mid);
|
|
461
|
+
upper = sorted.slice(mid);
|
|
462
|
+
} else {
|
|
463
|
+
medianVal = sorted[Math.floor(mid)];
|
|
464
|
+
lower = sorted.slice(0, Math.floor(mid));
|
|
465
|
+
upper = sorted.slice(Math.ceil(mid));
|
|
466
|
+
}
|
|
467
|
+
return [sorted[0], scalar(median())(lower), medianVal, scalar(median())(upper), sorted[sorted.length - 1]];
|
|
468
|
+
}, "peek")
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
__name(_quartile, "_quartile");
|
|
451
472
|
function quartile(callbackFn) {
|
|
452
|
-
|
|
473
|
+
return callbackFn ? Accessor(_quartile, callbackFn) : _quartile();
|
|
453
474
|
}
|
|
454
|
-
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/observers/reduce.ts
|
|
475
|
+
__name(quartile, "quartile");
|
|
457
476
|
function _reduce(callback, initialValue) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
477
|
+
let reduced;
|
|
478
|
+
return {
|
|
479
|
+
observe: /* @__PURE__ */ __name((value, idx) => {
|
|
480
|
+
if (idx === 0) {
|
|
481
|
+
reduced = initialValue === void 0 ? value : callback(initialValue, value, idx);
|
|
482
|
+
} else {
|
|
483
|
+
reduced = callback(reduced, value, idx);
|
|
484
|
+
}
|
|
485
|
+
}, "observe"),
|
|
486
|
+
peek: /* @__PURE__ */ __name(() => reduced, "peek")
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
__name(_reduce, "_reduce");
|
|
467
490
|
function reduce(callbackFn, initialValue) {
|
|
468
|
-
|
|
491
|
+
return _reduce(callbackFn, initialValue);
|
|
469
492
|
}
|
|
470
|
-
|
|
471
|
-
//#endregion
|
|
472
|
-
//#region src/utils/generate.ts
|
|
493
|
+
__name(reduce, "reduce");
|
|
473
494
|
function* generate(generatorFn, maxLen) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
495
|
+
let i = -1;
|
|
496
|
+
while (maxLen === void 0 || ++i < maxLen) {
|
|
497
|
+
yield generatorFn();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
__name(generate, "generate");
|
|
501
|
+
const GeneratorFunction = (function* () {
|
|
502
|
+
}).constructor;
|
|
481
503
|
function chainGen(...items) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
504
|
+
if (items[items.length - 1] instanceof GeneratorFunction) {
|
|
505
|
+
return function* (source) {
|
|
506
|
+
let tail = source;
|
|
507
|
+
for (const activity2 of items) {
|
|
508
|
+
tail = activity2(tail);
|
|
509
|
+
}
|
|
510
|
+
yield* tail;
|
|
511
|
+
};
|
|
512
|
+
} else {
|
|
513
|
+
return function(source) {
|
|
514
|
+
let tail = source;
|
|
515
|
+
for (const activity2 of items) {
|
|
516
|
+
tail = activity2(tail);
|
|
517
|
+
}
|
|
518
|
+
return tail;
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
__name(chainGen, "chainGen");
|
|
493
523
|
function pipe(s_or_ia, ...items) {
|
|
494
|
-
|
|
524
|
+
return isSource(s_or_ia) ? chainGen(...items)(s_or_ia) : chainGen(s_or_ia, ...items);
|
|
495
525
|
}
|
|
526
|
+
__name(pipe, "pipe");
|
|
496
527
|
const chain = pipe;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
528
|
+
export {
|
|
529
|
+
Accessor,
|
|
530
|
+
activity,
|
|
531
|
+
chain,
|
|
532
|
+
concat,
|
|
533
|
+
count,
|
|
534
|
+
deviation,
|
|
535
|
+
distribution,
|
|
536
|
+
each,
|
|
537
|
+
entries,
|
|
538
|
+
extent,
|
|
539
|
+
filter,
|
|
540
|
+
first,
|
|
541
|
+
generate,
|
|
542
|
+
group,
|
|
543
|
+
histogram,
|
|
544
|
+
isSource,
|
|
545
|
+
join,
|
|
546
|
+
map,
|
|
547
|
+
max,
|
|
548
|
+
mean,
|
|
549
|
+
median,
|
|
550
|
+
min,
|
|
551
|
+
normalize,
|
|
552
|
+
pipe,
|
|
553
|
+
quartile,
|
|
554
|
+
reduce,
|
|
555
|
+
scalar,
|
|
556
|
+
sensor,
|
|
557
|
+
skip,
|
|
558
|
+
sort,
|
|
559
|
+
variance
|
|
560
|
+
};
|
|
561
|
+
//# sourceMappingURL=index.js.map
|