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