@hpcc-js/dataflow 9.5.1 → 9.6.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/README.md +23 -23
- package/dist/index.js +1 -560
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +8 -5
- package/src/activities/histogram.ts +23 -2
- package/src/utils/pipe.ts +222 -63
- package/types/activities/histogram.d.ts +5 -0
- package/types/utils/pipe.d.ts +133 -40
package/dist/index.js
CHANGED
|
@@ -1,561 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function isSource(source) {
|
|
4
|
-
return source && (typeof source[Symbol.iterator] === "function" || Array.isArray(source));
|
|
5
|
-
}
|
|
6
|
-
__name(isSource, "isSource");
|
|
7
|
-
function concatGen(concatSource) {
|
|
8
|
-
return function* (source) {
|
|
9
|
-
yield* source;
|
|
10
|
-
yield* concatSource;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
__name(concatGen, "concatGen");
|
|
14
|
-
function concat(s_or_n, concatSource) {
|
|
15
|
-
return concatSource !== void 0 ? concatGen(concatSource)(s_or_n) : concatGen(s_or_n);
|
|
16
|
-
}
|
|
17
|
-
__name(concat, "concat");
|
|
18
|
-
function eachGen(callbackFn) {
|
|
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");
|
|
28
|
-
function each(s_or_cb, callbackFn) {
|
|
29
|
-
return isSource(s_or_cb) ? eachGen(callbackFn)(s_or_cb) : eachGen(s_or_cb);
|
|
30
|
-
}
|
|
31
|
-
__name(each, "each");
|
|
32
|
-
function entriesGen() {
|
|
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
|
-
function entries(source) {
|
|
42
|
-
return source ? entriesGen()(source) : entriesGen();
|
|
43
|
-
}
|
|
44
|
-
__name(entries, "entries");
|
|
45
|
-
function filterGen(callbackFn) {
|
|
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");
|
|
56
|
-
function filter(s_or_cb, callbackFn) {
|
|
57
|
-
return isSource(s_or_cb) ? filterGen(callbackFn)(s_or_cb) : filterGen(s_or_cb);
|
|
58
|
-
}
|
|
59
|
-
__name(filter, "filter");
|
|
60
|
-
function firstGen(n) {
|
|
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");
|
|
72
|
-
function first(s_or_n, n) {
|
|
73
|
-
if (!isSource(s_or_n)) return firstGen(s_or_n);
|
|
74
|
-
return firstGen(n)(s_or_n);
|
|
75
|
-
}
|
|
76
|
-
__name(first, "first");
|
|
77
|
-
function groupGen(groupFn) {
|
|
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");
|
|
94
|
-
function group(s_or_gbf, groupByFn) {
|
|
95
|
-
return isSource(s_or_gbf) ? groupGen(groupByFn)(s_or_gbf) : groupGen(s_or_gbf);
|
|
96
|
-
}
|
|
97
|
-
__name(group, "group");
|
|
98
|
-
function Accessor(fof, accesor) {
|
|
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");
|
|
108
|
-
function sensor(s) {
|
|
109
|
-
return each((r, i) => s.observe(r, i));
|
|
110
|
-
}
|
|
111
|
-
__name(sensor, "sensor");
|
|
112
|
-
function activity(s) {
|
|
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");
|
|
122
|
-
function scalar(s) {
|
|
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");
|
|
132
|
-
function _max() {
|
|
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");
|
|
146
|
-
function max(callbackFn) {
|
|
147
|
-
return callbackFn ? Accessor(_max, callbackFn) : _max();
|
|
148
|
-
}
|
|
149
|
-
__name(max, "max");
|
|
150
|
-
function _min() {
|
|
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");
|
|
164
|
-
function min(callbackFn) {
|
|
165
|
-
return callbackFn ? Accessor(_min, callbackFn) : _min();
|
|
166
|
-
}
|
|
167
|
-
__name(min, "min");
|
|
168
|
-
function _extent() {
|
|
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");
|
|
180
|
-
function extent(callbackFn) {
|
|
181
|
-
return callbackFn ? Accessor(_extent, callbackFn) : _extent();
|
|
182
|
-
}
|
|
183
|
-
__name(extent, "extent");
|
|
184
|
-
function isOptionA(_) {
|
|
185
|
-
return _.buckets !== void 0;
|
|
186
|
-
}
|
|
187
|
-
__name(isOptionA, "isOptionA");
|
|
188
|
-
function histogramGen(callbackFn, options) {
|
|
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");
|
|
241
|
-
function histogram(s_or_hf, hf_or_b, options) {
|
|
242
|
-
return isSource(s_or_hf) ? histogramGen(hf_or_b, options)(s_or_hf) : histogramGen(s_or_hf, hf_or_b);
|
|
243
|
-
}
|
|
244
|
-
__name(histogram, "histogram");
|
|
245
|
-
function joinGen(_sourceU, callbackFn) {
|
|
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");
|
|
255
|
-
function join(sT_or_sU, sU_or_cb, callbackFn) {
|
|
256
|
-
return isSource(sU_or_cb) ? joinGen(sU_or_cb, callbackFn)(sT_or_sU) : joinGen(sT_or_sU, sU_or_cb);
|
|
257
|
-
}
|
|
258
|
-
__name(join, "join");
|
|
259
|
-
function mapGen(callbackFn) {
|
|
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");
|
|
268
|
-
function map(s_or_cb, callbackFn) {
|
|
269
|
-
return isSource(s_or_cb) ? mapGen(callbackFn)(s_or_cb) : mapGen(s_or_cb);
|
|
270
|
-
}
|
|
271
|
-
__name(map, "map");
|
|
272
|
-
function normalizeGen() {
|
|
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");
|
|
283
|
-
function normalize(s_or_undef) {
|
|
284
|
-
return isSource(s_or_undef) ? normalizeGen()(s_or_undef) : normalizeGen();
|
|
285
|
-
}
|
|
286
|
-
__name(normalize, "normalize");
|
|
287
|
-
function skipGen(n) {
|
|
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");
|
|
298
|
-
function skip(s_or_n, n) {
|
|
299
|
-
return isSource(s_or_n) ? skipGen(n)(s_or_n) : skipGen(s_or_n);
|
|
300
|
-
}
|
|
301
|
-
__name(skip, "skip");
|
|
302
|
-
function sortGen(compareFn) {
|
|
303
|
-
return function* (source) {
|
|
304
|
-
yield* (Array.isArray(source) ? source : [...source]).sort(compareFn);
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
__name(sortGen, "sortGen");
|
|
308
|
-
function sort(s_or_cb, callbackFn) {
|
|
309
|
-
return isSource(s_or_cb) ? sortGen(callbackFn)(s_or_cb) : sortGen(s_or_cb);
|
|
310
|
-
}
|
|
311
|
-
__name(sort, "sort");
|
|
312
|
-
function count() {
|
|
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");
|
|
325
|
-
function _variance() {
|
|
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");
|
|
344
|
-
function variance(callbackFn) {
|
|
345
|
-
return callbackFn ? Accessor(_variance, callbackFn) : _variance();
|
|
346
|
-
}
|
|
347
|
-
__name(variance, "variance");
|
|
348
|
-
function _deviation() {
|
|
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");
|
|
361
|
-
function deviation(callbackFn) {
|
|
362
|
-
return callbackFn ? Accessor(_deviation, callbackFn) : _deviation();
|
|
363
|
-
}
|
|
364
|
-
__name(deviation, "deviation");
|
|
365
|
-
function _mean() {
|
|
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");
|
|
381
|
-
function mean(callbackFn) {
|
|
382
|
-
return callbackFn ? Accessor(_mean, callbackFn) : _mean();
|
|
383
|
-
}
|
|
384
|
-
__name(mean, "mean");
|
|
385
|
-
function _distribution() {
|
|
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");
|
|
412
|
-
function distribution(callbackFn) {
|
|
413
|
-
return callbackFn ? Accessor(_distribution, callbackFn) : _distribution();
|
|
414
|
-
}
|
|
415
|
-
__name(distribution, "distribution");
|
|
416
|
-
function _median() {
|
|
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");
|
|
437
|
-
function median(callbackFn) {
|
|
438
|
-
return callbackFn ? Accessor(_median, callbackFn) : _median();
|
|
439
|
-
}
|
|
440
|
-
__name(median, "median");
|
|
441
|
-
function _quartile() {
|
|
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");
|
|
472
|
-
function quartile(callbackFn) {
|
|
473
|
-
return callbackFn ? Accessor(_quartile, callbackFn) : _quartile();
|
|
474
|
-
}
|
|
475
|
-
__name(quartile, "quartile");
|
|
476
|
-
function _reduce(callback, initialValue) {
|
|
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");
|
|
490
|
-
function reduce(callbackFn, initialValue) {
|
|
491
|
-
return _reduce(callbackFn, initialValue);
|
|
492
|
-
}
|
|
493
|
-
__name(reduce, "reduce");
|
|
494
|
-
function* generate(generatorFn, maxLen) {
|
|
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;
|
|
503
|
-
function chainGen(...items) {
|
|
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");
|
|
523
|
-
function pipe(s_or_ia, ...items) {
|
|
524
|
-
return isSource(s_or_ia) ? chainGen(...items)(s_or_ia) : chainGen(s_or_ia, ...items);
|
|
525
|
-
}
|
|
526
|
-
__name(pipe, "pipe");
|
|
527
|
-
const chain = pipe;
|
|
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
|
-
};
|
|
1
|
+
var e=Object.defineProperty,n=(n,t)=>e(n,"name",{value:t,configurable:!0});function t(e){return e&&("function"==typeof e[Symbol.iterator]||Array.isArray(e))}function r(e){return function*(n){yield*n,yield*e}}function o(e,n){return void 0!==n?r(n)(e):r(e)}function i(e){return function*(n){let t=-1;for(const r of n)e(r,++t),yield r}}function u(e,n){return t(e)?i(n)(e):i(e)}function c(){return function*(e){let n=-1;for(const t of e)yield[++n,t]}}function f(e){return e?function*(e){let n=-1;for(const t of e)yield[++n,t]}(e):function*(e){let n=-1;for(const t of e)yield[++n,t]}}function s(e){return function*(n){let t=-1;for(const r of n)e(r,++t)&&(yield r)}}function l(e,n){return t(e)?s(n)(e):s(e)}function a(e){return function*(n){let t=0;for(const r of n)if(yield r,++t>=e)break}}function v(e,n){return t(e)?a(n)(e):a(e)}function p(e){return function*(n){let t=-1;const r={};for(const o of n){const n=e(o,++t);r[n]||(r[n]=[]),r[n].push(o)}for(const e in r)yield{key:e,value:r[e]}}}function b(e,n){return t(e)?p(n)(e):p(e)}function d(e,t){const r=e();return{observe:/* @__PURE__ */n((e,n)=>{r.observe(t(e,n),n)},"observe"),peek:r.peek}}function k(e){return u((n,t)=>e.observe(n,t))}function y(e){return function*(n){let t=-1;for(const r of n)e.observe(r,++t);yield e.peek()}}function h(e){return function(n){let t=-1;for(const r of n)e.observe(r,++t);return e.peek()}}function m(){let e;return{observe:/* @__PURE__ */n((n,t)=>{(0===t||e<n)&&(e=n)},"observe"),peek:/* @__PURE__ */n(()=>e,"peek")}}function g(e){return e?d(m,e):m()}function G(){let e;return{observe:/* @__PURE__ */n((n,t)=>{(0===t||e>n)&&(e=n)},"observe"),peek:/* @__PURE__ */n(()=>e,"peek")}}function A(e){return e?d(G,e):G()}function _(){const e=A(),t=g();return{observe:/* @__PURE__ */n((n,r)=>{e.observe(n,r),t.observe(n,r)},"observe"),peek:/* @__PURE__ */n(()=>[e.peek(),t.peek()],"peek")}}function x(e){return e?d(_,e):_()}function M(e){return void 0!==e.buckets}function q(e,n){return function*(t){let r,o,i;if(M(n)){i=Array.isArray(t)?t:[...t];const u=h(x(e))(i);if(void 0===u||void 0===u[0]||void 0===u[1]){const e=n.buckets;for(let n=0;n<e;++n)yield{from:NaN,to:NaN,value:[]};return}r=u[0];o=(u[1]-r)/n.buckets}else i=t,r=n.min,o=n.range;const u={};let c=0,f=!1;for(const n of i){f=!0;const t=e(n),i=Math.floor((t-r)/o);c<i&&(c=i),void 0===u[i]&&(u[i]=[]),u[i].push(n)}if(!f)return;const s=u[c],l=r+c*o;for(let n=0;n<=c;++n){if(n===c-1&&s.every(n=>l===e(n))){yield{from:r+n*o,to:r+(n+1)*o,value:[...u[n]||[],...s]};break}yield{from:r+n*o,to:r+(n+1)*o,value:u[n]||[]}}}}function N(e,n,r){return t(e)?q(n,r)(e):q(e,n)}function j(e,n){const t=Array.isArray(e)?e[Symbol.iterator]():e;return function*(e){let r=-1;for(const o of e)yield n(o,t.next().value,++r)}}function S(e,n,r){return t(n)?j(n,r)(e):j(e,n)}function w(e){return function*(n){let t=-1;for(const r of n)yield e(r,++t)}}function z(e,n){return t(e)?w(n)(e):w(e)}function O(){const e=h(x());return function*(n){const t=Array.isArray(n)?n:[...n],r=e(t),o=r[1]-r[0]||1,i=z(e=>(e-r[0])/o);return yield*i(t)}}function E(e){return t(e)?O()(e):O()}function P(e){return function*(n){let t=-1;for(const r of n)++t>=e&&(yield r)}}function T(e,n){return t(e)?P(n)(e):P(e)}function B(e){return function*(n){yield*(Array.isArray(n)?n:[...n]).sort(e)}}function C(e,n){return t(e)?B(n)(e):B(e)}function D(){let e;return{observe:/* @__PURE__ */n((n,t)=>{0===t&&(e=0),++e},"observe"),peek:/* @__PURE__ */n(()=>e,"peek")}}function F(){let e,t,r;return{observe:/* @__PURE__ */n((n,o)=>{0===o&&(e=0,t=0,r=0);const i=n-t;t+=i/++e,r+=i*(n-t)},"observe"),peek:/* @__PURE__ */n(()=>e>1?r/(e-1):void 0,"peek")}}function H(e){return e?d(F,e):F()}function I(){const e=H();return{observe:/* @__PURE__ */n((n,t)=>{e.observe(n,t)},"observe"),peek:/* @__PURE__ */n(()=>{const n=e.peek();return void 0!==n?Math.sqrt(n):n},"peek")}}function J(e){return e?d(I,e):I()}function K(){let e,t;return{observe:/* @__PURE__ */n((n,r)=>{0===r?e=n:e+=n,t=r},"observe"),peek:/* @__PURE__ */n(()=>e/(t+1),"peek")}}function L(e){return e?d(K,e):K()}function Q(){const e=A(),t=g(),r=L(),o=H();return{observe:/* @__PURE__ */n((n,i)=>{e.observe(n,i),t.observe(n,i),r.observe(n,i),o.observe(n,i)},"observe"),peek:/* @__PURE__ */n(()=>{const n=e.peek();if(void 0===n)return;const i=o.peek();return{min:n,max:t.peek(),mean:r.peek(),variance:i,deviation:void 0!==i?Math.sqrt(i):void 0}},"peek")}}function R(e){return e?d(Q,e):Q()}function U(){let e;return{observe:/* @__PURE__ */n((n,t)=>{0===t&&(e=[]),e.push(n)},"observe"),peek:/* @__PURE__ */n(()=>{const n=e.sort((e,n)=>e-n),t=n.length/2;return n.length%2==0?(n[t-1]+n[t])/2:n[Math.floor(t)]},"peek")}}function V(e){return e?d(U,e):U()}function W(){let e;return{observe:/* @__PURE__ */n((n,t)=>{0===t&&(e=[]),e.push(n)},"observe"),peek:/* @__PURE__ */n(()=>{const n=e.sort((e,n)=>e-n),t=n.length/2;let r,o,i;if(!(n.length<2))return n.length%2==0?(r=(n[t-1]+n[t])/2,o=n.slice(0,t),i=n.slice(t)):(r=n[Math.floor(t)],o=n.slice(0,Math.floor(t)),i=n.slice(Math.ceil(t))),[n[0],h(V())(o),r,h(V())(i),n[n.length-1]]},"peek")}}function X(e){return e?d(W,e):W()}function Y(e,t){let r;return{observe:/* @__PURE__ */n((n,o)=>{r=0===o?void 0===t?n:e(t,n,o):e(r,n,o)},"observe"),peek:/* @__PURE__ */n(()=>r,"peek")}}function Z(e,n){return Y(e,n)}function*$(e,n){let t=-1;for(;void 0===n||++t<n;)yield e()}n(t,"isSource"),n(r,"concatGen"),n(o,"concat"),n(i,"eachGen"),n(u,"each"),n(c,"entriesGen"),n(f,"entries"),n(s,"filterGen"),n(l,"filter"),n(a,"firstGen"),n(v,"first"),n(p,"groupGen"),n(b,"group"),n(d,"Accessor"),n(k,"sensor"),n(y,"activity"),n(h,"scalar"),n(m,"_max"),n(g,"max"),n(G,"_min"),n(A,"min"),n(_,"_extent"),n(x,"extent"),n(M,"isOptionA"),n(q,"histogramGen"),n(N,"histogram"),n(j,"joinGen"),n(S,"join"),n(w,"mapGen"),n(z,"map"),n(O,"normalizeGen"),n(E,"normalize"),n(P,"skipGen"),n(T,"skip"),n(B,"sortGen"),n(C,"sort"),n(D,"count"),n(F,"_variance"),n(H,"variance"),n(I,"_deviation"),n(J,"deviation"),n(K,"_mean"),n(L,"mean"),n(Q,"_distribution"),n(R,"distribution"),n(U,"_median"),n(V,"median"),n(W,"_quartile"),n(X,"quartile"),n(Y,"_reduce"),n(Z,"reduce"),n($,"generate");const ee=function*(){}.constructor;function ne(...e){if(0===e.length)return e=>e;const n=e[e.length-1]instanceof ee,t=e.length;return n?function*(n){let r=n;for(let o=0;o<t;o++)r=e[o](r);yield*r}:n=>{let r=n;for(let o=0;o<t;o++)r=e[o](r);return r}}function te(...e){if(0===e.length)throw new TypeError("pipe requires at least one argument");return t(e[0])?1===e.length?e[0]:ne(...e.slice(1))(e[0]):ne(...e)}n(ne,"chainGen"),n(te,"pipe");const re=te;export{d as Accessor,y as activity,re as chain,o as concat,D as count,J as deviation,R as distribution,u as each,f as entries,x as extent,l as filter,v as first,$ as generate,b as group,N as histogram,t as isSource,S as join,z as map,g as max,L as mean,V as median,A as min,E as normalize,te as pipe,X as quartile,Z as reduce,h as scalar,k as sensor,T as skip,C as sort,H as variance};
|
|
561
2
|
//# sourceMappingURL=index.js.map
|