@hpcc-js/dataflow 9.2.0 → 9.2.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/LICENSE +43 -43
- package/README.md +530 -530
- package/dist/index.js +557 -1
- package/dist/index.js.map +1 -7
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/lib-es6/__package__.js +4 -0
- package/lib-es6/__package__.js.map +1 -0
- package/lib-es6/__tests__/chain.js +49 -0
- package/lib-es6/__tests__/chain.js.map +1 -0
- package/lib-es6/__tests__/concat.js +17 -0
- package/lib-es6/__tests__/concat.js.map +1 -0
- package/lib-es6/__tests__/count.js +19 -0
- package/lib-es6/__tests__/count.js.map +1 -0
- package/lib-es6/__tests__/data.js +56 -0
- package/lib-es6/__tests__/data.js.map +1 -0
- package/lib-es6/__tests__/deviation.js +13 -0
- package/lib-es6/__tests__/deviation.js.map +1 -0
- package/lib-es6/__tests__/distribution.js +19 -0
- package/lib-es6/__tests__/distribution.js.map +1 -0
- package/lib-es6/__tests__/each.js +12 -0
- package/lib-es6/__tests__/each.js.map +1 -0
- package/lib-es6/__tests__/entries.js +13 -0
- package/lib-es6/__tests__/entries.js.map +1 -0
- package/lib-es6/__tests__/extent.js +19 -0
- package/lib-es6/__tests__/extent.js.map +1 -0
- package/lib-es6/__tests__/filter.js +14 -0
- package/lib-es6/__tests__/filter.js.map +1 -0
- package/lib-es6/__tests__/first.js +14 -0
- package/lib-es6/__tests__/first.js.map +1 -0
- package/lib-es6/__tests__/generate.js +8 -0
- package/lib-es6/__tests__/generate.js.map +1 -0
- package/lib-es6/__tests__/group.js +18 -0
- package/lib-es6/__tests__/group.js.map +1 -0
- package/lib-es6/__tests__/histogram.js +42 -0
- package/lib-es6/__tests__/histogram.js.map +1 -0
- package/lib-es6/__tests__/index.js +28 -0
- package/lib-es6/__tests__/index.js.map +1 -0
- package/lib-es6/__tests__/join.js +16 -0
- package/lib-es6/__tests__/join.js.map +1 -0
- package/lib-es6/__tests__/map.js +14 -0
- package/lib-es6/__tests__/map.js.map +1 -0
- package/lib-es6/__tests__/max.js +30 -0
- package/lib-es6/__tests__/max.js.map +1 -0
- package/lib-es6/__tests__/mean.js +10 -0
- package/lib-es6/__tests__/mean.js.map +1 -0
- package/lib-es6/__tests__/median.js +13 -0
- package/lib-es6/__tests__/median.js.map +1 -0
- package/lib-es6/__tests__/min.js +30 -0
- package/lib-es6/__tests__/min.js.map +1 -0
- package/lib-es6/__tests__/normalize.js +12 -0
- package/lib-es6/__tests__/normalize.js.map +1 -0
- package/lib-es6/__tests__/quartile.js +12 -0
- package/lib-es6/__tests__/quartile.js.map +1 -0
- package/lib-es6/__tests__/readme.js +96 -0
- package/lib-es6/__tests__/readme.js.map +1 -0
- package/lib-es6/__tests__/reduce.js +15 -0
- package/lib-es6/__tests__/reduce.js.map +1 -0
- package/lib-es6/__tests__/skip.js +14 -0
- package/lib-es6/__tests__/skip.js.map +1 -0
- package/lib-es6/__tests__/sort.js +19 -0
- package/lib-es6/__tests__/sort.js.map +1 -0
- package/lib-es6/__tests__/variance.js +13 -0
- package/lib-es6/__tests__/variance.js.map +1 -0
- package/lib-es6/activities/activity.js +4 -0
- package/lib-es6/activities/activity.js.map +1 -0
- package/lib-es6/activities/concat.js +10 -0
- package/lib-es6/activities/concat.js.map +1 -0
- package/lib-es6/activities/each.js +14 -0
- package/lib-es6/activities/each.js.map +1 -0
- package/lib-es6/activities/entries.js +13 -0
- package/lib-es6/activities/entries.js.map +1 -0
- package/lib-es6/activities/filter.js +15 -0
- package/lib-es6/activities/filter.js.map +1 -0
- package/lib-es6/activities/first.js +18 -0
- package/lib-es6/activities/first.js.map +1 -0
- package/lib-es6/activities/group.js +21 -0
- package/lib-es6/activities/group.js.map +1 -0
- package/lib-es6/activities/histogram.js +64 -0
- package/lib-es6/activities/histogram.js.map +1 -0
- package/lib-es6/activities/join.js +14 -0
- package/lib-es6/activities/join.js.map +1 -0
- package/lib-es6/activities/map.js +13 -0
- package/lib-es6/activities/map.js.map +1 -0
- package/lib-es6/activities/normalize.js +18 -0
- package/lib-es6/activities/normalize.js.map +1 -0
- package/lib-es6/activities/skip.js +15 -0
- package/lib-es6/activities/skip.js.map +1 -0
- package/lib-es6/activities/sort.js +10 -0
- package/lib-es6/activities/sort.js.map +1 -0
- package/lib-es6/index.js +28 -0
- package/lib-es6/index.js.map +1 -0
- package/lib-es6/observers/count.js +13 -0
- package/lib-es6/observers/count.js.map +1 -0
- package/lib-es6/observers/deviation.js +18 -0
- package/lib-es6/observers/deviation.js.map +1 -0
- package/lib-es6/observers/distribution.js +36 -0
- package/lib-es6/observers/distribution.js.map +1 -0
- package/lib-es6/observers/extent.js +18 -0
- package/lib-es6/observers/extent.js.map +1 -0
- package/lib-es6/observers/max.js +19 -0
- package/lib-es6/observers/max.js.map +1 -0
- package/lib-es6/observers/mean.js +21 -0
- package/lib-es6/observers/mean.js.map +1 -0
- package/lib-es6/observers/median.js +26 -0
- package/lib-es6/observers/median.js.map +1 -0
- package/lib-es6/observers/min.js +19 -0
- package/lib-es6/observers/min.js.map +1 -0
- package/lib-es6/observers/observer.js +35 -0
- package/lib-es6/observers/observer.js.map +1 -0
- package/lib-es6/observers/quartile.js +38 -0
- package/lib-es6/observers/quartile.js.map +1 -0
- package/lib-es6/observers/reduce.js +18 -0
- package/lib-es6/observers/reduce.js.map +1 -0
- package/lib-es6/observers/variance.js +23 -0
- package/lib-es6/observers/variance.js.map +1 -0
- package/lib-es6/utils/generate.js +7 -0
- package/lib-es6/utils/generate.js.map +1 -0
- package/lib-es6/utils/pipe.js +32 -0
- package/lib-es6/utils/pipe.js.map +1 -0
- package/package.json +37 -28
- package/src/__package__.ts +3 -3
- package/src/__tests__/chain.ts +85 -0
- package/src/__tests__/concat.ts +18 -0
- package/src/__tests__/count.ts +25 -0
- package/src/__tests__/data.ts +64 -0
- package/src/__tests__/deviation.ts +14 -0
- package/src/__tests__/distribution.ts +21 -0
- package/src/__tests__/each.ts +13 -0
- package/src/__tests__/entries.ts +14 -0
- package/src/__tests__/extent.ts +25 -0
- package/src/__tests__/filter.ts +16 -0
- package/src/__tests__/first.ts +15 -0
- package/src/__tests__/generate.ts +9 -0
- package/src/__tests__/group.ts +19 -0
- package/src/__tests__/histogram.ts +47 -0
- package/src/__tests__/index.ts +27 -0
- package/src/__tests__/join.ts +20 -0
- package/src/__tests__/map.ts +16 -0
- package/src/__tests__/max.ts +42 -0
- package/src/__tests__/mean.ts +11 -0
- package/src/__tests__/median.ts +14 -0
- package/src/__tests__/min.ts +42 -0
- package/src/__tests__/normalize.ts +14 -0
- package/src/__tests__/quartile.ts +14 -0
- package/src/__tests__/readme.ts +113 -0
- package/src/__tests__/reduce.ts +17 -0
- package/src/__tests__/skip.ts +15 -0
- package/src/__tests__/sort.ts +21 -0
- package/src/__tests__/variance.ts +14 -0
- package/src/activities/activity.ts +8 -8
- package/src/activities/concat.ts +14 -14
- package/src/activities/each.ts +19 -19
- package/src/activities/entries.ts +17 -17
- package/src/activities/filter.ts +20 -20
- package/src/activities/first.ts +20 -20
- package/src/activities/group.ts +27 -27
- package/src/activities/histogram.ts +78 -78
- package/src/activities/join.ts +19 -19
- package/src/activities/map.ts +18 -18
- package/src/activities/normalize.ts +21 -21
- package/src/activities/skip.ts +18 -18
- package/src/activities/sort.ts +16 -16
- package/src/index.ts +27 -27
- package/src/observers/count.ts +15 -15
- package/src/observers/deviation.ts +24 -24
- package/src/observers/distribution.ts +51 -51
- package/src/observers/extent.ts +24 -24
- package/src/observers/max.ts +24 -24
- package/src/observers/mean.ts +26 -26
- package/src/observers/median.ts +30 -30
- package/src/observers/min.ts +24 -24
- package/src/observers/observer.ts +52 -52
- package/src/observers/quartile.ts +43 -43
- package/src/observers/reduce.ts +22 -22
- package/src/observers/variance.ts +29 -29
- package/src/utils/generate.ts +6 -6
- package/src/utils/pipe.ts +74 -74
- package/types/__package__.d.ts +4 -0
- package/types/__package__.d.ts.map +1 -0
- package/types/__tests__/chain.d.ts +2 -0
- package/types/__tests__/chain.d.ts.map +1 -0
- package/types/__tests__/concat.d.ts +2 -0
- package/types/__tests__/concat.d.ts.map +1 -0
- package/types/__tests__/count.d.ts +2 -0
- package/types/__tests__/count.d.ts.map +1 -0
- package/types/__tests__/data.d.ts +62 -0
- package/types/__tests__/data.d.ts.map +1 -0
- package/types/__tests__/deviation.d.ts +2 -0
- package/types/__tests__/deviation.d.ts.map +1 -0
- package/types/__tests__/distribution.d.ts +2 -0
- package/types/__tests__/distribution.d.ts.map +1 -0
- package/types/__tests__/each.d.ts +2 -0
- package/types/__tests__/each.d.ts.map +1 -0
- package/types/__tests__/entries.d.ts +2 -0
- package/types/__tests__/entries.d.ts.map +1 -0
- package/types/__tests__/extent.d.ts +2 -0
- package/types/__tests__/extent.d.ts.map +1 -0
- package/types/__tests__/filter.d.ts +2 -0
- package/types/__tests__/filter.d.ts.map +1 -0
- package/types/__tests__/first.d.ts +2 -0
- package/types/__tests__/first.d.ts.map +1 -0
- package/types/__tests__/generate.d.ts +2 -0
- package/types/__tests__/generate.d.ts.map +1 -0
- package/types/__tests__/group.d.ts +2 -0
- package/types/__tests__/group.d.ts.map +1 -0
- package/types/__tests__/histogram.d.ts +2 -0
- package/types/__tests__/histogram.d.ts.map +1 -0
- package/types/__tests__/index.d.ts +28 -0
- package/types/__tests__/index.d.ts.map +1 -0
- package/types/__tests__/join.d.ts +2 -0
- package/types/__tests__/join.d.ts.map +1 -0
- package/types/__tests__/map.d.ts +2 -0
- package/types/__tests__/map.d.ts.map +1 -0
- package/types/__tests__/max.d.ts +2 -0
- package/types/__tests__/max.d.ts.map +1 -0
- package/types/__tests__/mean.d.ts +2 -0
- package/types/__tests__/mean.d.ts.map +1 -0
- package/types/__tests__/median.d.ts +2 -0
- package/types/__tests__/median.d.ts.map +1 -0
- package/types/__tests__/min.d.ts +2 -0
- package/types/__tests__/min.d.ts.map +1 -0
- package/types/__tests__/normalize.d.ts +2 -0
- package/types/__tests__/normalize.d.ts.map +1 -0
- package/types/__tests__/quartile.d.ts +2 -0
- package/types/__tests__/quartile.d.ts.map +1 -0
- package/types/__tests__/readme.d.ts +2 -0
- package/types/__tests__/readme.d.ts.map +1 -0
- package/types/__tests__/reduce.d.ts +2 -0
- package/types/__tests__/reduce.d.ts.map +1 -0
- package/types/__tests__/skip.d.ts +2 -0
- package/types/__tests__/skip.d.ts.map +1 -0
- package/types/__tests__/sort.d.ts +2 -0
- package/types/__tests__/sort.d.ts.map +1 -0
- package/types/__tests__/variance.d.ts +2 -0
- package/types/__tests__/variance.d.ts.map +1 -0
- package/types/activities/activity.d.ts +1 -0
- package/types/activities/activity.d.ts.map +1 -0
- package/types/activities/concat.d.ts +2 -1
- package/types/activities/concat.d.ts.map +1 -0
- package/types/activities/each.d.ts +2 -1
- package/types/activities/each.d.ts.map +1 -0
- package/types/activities/entries.d.ts +2 -1
- package/types/activities/entries.d.ts.map +1 -0
- package/types/activities/filter.d.ts +2 -1
- package/types/activities/filter.d.ts.map +1 -0
- package/types/activities/first.d.ts +2 -1
- package/types/activities/first.d.ts.map +1 -0
- package/types/activities/group.d.ts +2 -1
- package/types/activities/group.d.ts.map +1 -0
- package/types/activities/histogram.d.ts +2 -1
- package/types/activities/histogram.d.ts.map +1 -0
- package/types/activities/join.d.ts +2 -1
- package/types/activities/join.d.ts.map +1 -0
- package/types/activities/map.d.ts +2 -1
- package/types/activities/map.d.ts.map +1 -0
- package/types/activities/normalize.d.ts +2 -1
- package/types/activities/normalize.d.ts.map +1 -0
- package/types/activities/skip.d.ts +2 -1
- package/types/activities/skip.d.ts.map +1 -0
- package/types/activities/sort.d.ts +2 -1
- package/types/activities/sort.d.ts.map +1 -0
- package/types/index.d.ts +28 -27
- package/types/index.d.ts.map +1 -0
- package/types/observers/count.d.ts +2 -1
- package/types/observers/count.d.ts.map +1 -0
- package/types/observers/deviation.d.ts +2 -1
- package/types/observers/deviation.d.ts.map +1 -0
- package/types/observers/distribution.d.ts +2 -1
- package/types/observers/distribution.d.ts.map +1 -0
- package/types/observers/extent.d.ts +2 -1
- package/types/observers/extent.d.ts.map +1 -0
- package/types/observers/max.d.ts +2 -1
- package/types/observers/max.d.ts.map +1 -0
- package/types/observers/mean.d.ts +2 -1
- package/types/observers/mean.d.ts.map +1 -0
- package/types/observers/median.d.ts +2 -1
- package/types/observers/median.d.ts.map +1 -0
- package/types/observers/min.d.ts +2 -1
- package/types/observers/min.d.ts.map +1 -0
- package/types/observers/observer.d.ts +3 -2
- package/types/observers/observer.d.ts.map +1 -0
- package/types/observers/quartile.d.ts +2 -1
- package/types/observers/quartile.d.ts.map +1 -0
- package/types/observers/reduce.d.ts +2 -1
- package/types/observers/reduce.d.ts.map +1 -0
- package/types/observers/variance.d.ts +2 -1
- package/types/observers/variance.d.ts.map +1 -0
- package/types/utils/generate.d.ts +1 -0
- package/types/utils/generate.d.ts.map +1 -0
- package/types/utils/pipe.d.ts +2 -1
- package/types/utils/pipe.d.ts.map +1 -0
- package/types-3.4/__package__.d.ts +4 -0
- package/types-3.4/__tests__/chain.d.ts +2 -0
- package/types-3.4/__tests__/concat.d.ts +2 -0
- package/types-3.4/__tests__/count.d.ts +2 -0
- package/types-3.4/__tests__/data.d.ts +62 -0
- package/types-3.4/__tests__/deviation.d.ts +2 -0
- package/types-3.4/__tests__/distribution.d.ts +2 -0
- package/types-3.4/__tests__/each.d.ts +2 -0
- package/types-3.4/__tests__/entries.d.ts +2 -0
- package/types-3.4/__tests__/extent.d.ts +2 -0
- package/types-3.4/__tests__/filter.d.ts +2 -0
- package/types-3.4/__tests__/first.d.ts +2 -0
- package/types-3.4/__tests__/generate.d.ts +2 -0
- package/types-3.4/__tests__/group.d.ts +2 -0
- package/types-3.4/__tests__/histogram.d.ts +2 -0
- package/types-3.4/__tests__/index.d.ts +28 -0
- package/types-3.4/__tests__/join.d.ts +2 -0
- package/types-3.4/__tests__/map.d.ts +2 -0
- package/types-3.4/__tests__/max.d.ts +2 -0
- package/types-3.4/__tests__/mean.d.ts +2 -0
- package/types-3.4/__tests__/median.d.ts +2 -0
- package/types-3.4/__tests__/min.d.ts +2 -0
- package/types-3.4/__tests__/normalize.d.ts +2 -0
- package/types-3.4/__tests__/quartile.d.ts +2 -0
- package/types-3.4/__tests__/readme.d.ts +2 -0
- package/types-3.4/__tests__/reduce.d.ts +2 -0
- package/types-3.4/__tests__/skip.d.ts +2 -0
- package/types-3.4/__tests__/sort.d.ts +2 -0
- package/types-3.4/__tests__/variance.d.ts +2 -0
- package/types-3.4/activities/activity.d.ts +6 -0
- package/types-3.4/activities/concat.d.ts +4 -0
- package/types-3.4/activities/each.d.ts +5 -0
- package/types-3.4/activities/entries.d.ts +10 -0
- package/types-3.4/activities/filter.d.ts +5 -0
- package/types-3.4/activities/first.d.ts +4 -0
- package/types-3.4/activities/group.d.ts +9 -0
- package/types-3.4/activities/histogram.d.ts +18 -0
- package/types-3.4/activities/join.d.ts +5 -0
- package/types-3.4/activities/map.d.ts +5 -0
- package/types-3.4/activities/normalize.d.ts +4 -0
- package/types-3.4/activities/skip.d.ts +4 -0
- package/types-3.4/activities/sort.d.ts +5 -0
- package/types-3.4/index.d.ts +28 -0
- package/types-3.4/observers/count.d.ts +3 -0
- package/types-3.4/observers/deviation.d.ts +5 -0
- package/types-3.4/observers/distribution.d.ts +13 -0
- package/types-3.4/observers/extent.d.ts +11 -0
- package/types-3.4/observers/max.d.ts +5 -0
- package/types-3.4/observers/mean.d.ts +5 -0
- package/types-3.4/observers/median.d.ts +5 -0
- package/types-3.4/observers/min.d.ts +5 -0
- package/types-3.4/observers/observer.d.ts +14 -0
- package/types-3.4/observers/quartile.d.ts +12 -0
- package/types-3.4/observers/reduce.d.ts +4 -0
- package/types-3.4/observers/variance.d.ts +5 -0
- package/types-3.4/utils/generate.d.ts +2 -0
- package/types-3.4/utils/pipe.d.ts +42 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { each } from "../activities/each";
|
|
2
|
+
export function Accessor(fof, accesor) {
|
|
3
|
+
const s = fof();
|
|
4
|
+
return {
|
|
5
|
+
observe: (_, i) => {
|
|
6
|
+
s.observe(accesor(_, i), i);
|
|
7
|
+
},
|
|
8
|
+
peek: s.peek
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
// This is an pass through activity so a FlowObserver can be inserted into a pipeline ---
|
|
12
|
+
export function sensor(s) {
|
|
13
|
+
return each((r, i) => s.observe(r, i));
|
|
14
|
+
}
|
|
15
|
+
// This converts a FlowObserver to an Activity ---
|
|
16
|
+
export function activity(s) {
|
|
17
|
+
return function* (source) {
|
|
18
|
+
let i = -1;
|
|
19
|
+
for (const row of source) {
|
|
20
|
+
s.observe(row, ++i);
|
|
21
|
+
}
|
|
22
|
+
yield s.peek();
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// This converts a FlowObserver to an ScalarActivity ---
|
|
26
|
+
export function scalar(s) {
|
|
27
|
+
return function (source) {
|
|
28
|
+
let i = -1;
|
|
29
|
+
for (const row of source) {
|
|
30
|
+
s.observe(row, ++i);
|
|
31
|
+
}
|
|
32
|
+
return s.peek();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.js","sourceRoot":"","sources":["../../src/observers/observer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAa1C,MAAM,UAAU,QAAQ,CAA4B,GAA0B,EAAE,OAAwB;IACpG,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;IAEhB,OAAO;QACH,OAAO,EAAE,CAAC,CAAI,EAAE,CAAS,EAAE,EAAE;YACzB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,CAAC,CAAC,IAAI;KACf,CAAC;AACN,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,MAAM,CAAa,CAAiB;IAChD,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,QAAQ,CAAO,CAAiB;IAC5C,OAAO,QAAQ,CAAC,EAAE,MAAiB;QAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACX,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC;AACN,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,MAAM,CAAmB,CAAiB;IACtD,OAAO,UAAU,MAAiB;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACX,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { median } from "./median";
|
|
2
|
+
import { Accessor, scalar } from "./observer";
|
|
3
|
+
function _quartile() {
|
|
4
|
+
let values;
|
|
5
|
+
return {
|
|
6
|
+
observe: (value, idx) => {
|
|
7
|
+
if (idx === 0) {
|
|
8
|
+
values = [];
|
|
9
|
+
}
|
|
10
|
+
values.push(value);
|
|
11
|
+
},
|
|
12
|
+
peek: () => {
|
|
13
|
+
const sorted = values.sort((l, r) => l - r);
|
|
14
|
+
const mid = sorted.length / 2;
|
|
15
|
+
let medianVal;
|
|
16
|
+
let lower;
|
|
17
|
+
let upper;
|
|
18
|
+
if (sorted.length < 2) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
else if (sorted.length % 2 === 0) {
|
|
22
|
+
medianVal = (sorted[mid - 1] + sorted[mid]) / 2;
|
|
23
|
+
lower = sorted.slice(0, mid);
|
|
24
|
+
upper = sorted.slice(mid);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
medianVal = sorted[Math.floor(mid)];
|
|
28
|
+
lower = sorted.slice(0, Math.floor(mid));
|
|
29
|
+
upper = sorted.slice(Math.ceil(mid));
|
|
30
|
+
}
|
|
31
|
+
return [sorted[0], scalar(median())(lower), medianVal, scalar(median())(upper), sorted[sorted.length - 1]];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function quartile(callbackFn) {
|
|
36
|
+
return callbackFn ? Accessor(_quartile, callbackFn) : _quartile();
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=quartile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quartile.js","sourceRoot":"","sources":["../../src/observers/quartile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAuB,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAMnE,SAAS,SAAS;IACd,IAAI,MAAgB,CAAC;IAErB,OAAO;QACH,OAAO,EAAE,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;YACpC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;gBACZ,MAAM,GAAG,EAAE,CAAC;YAChB,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACP,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9B,IAAI,SAAiB,CAAC;YACtB,IAAI,KAAe,CAAC;YACpB,IAAI,KAAe,CAAC;YACpB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,OAAO,SAAS,CAAC;YACrB,CAAC;iBAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,SAAS,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;gBAChD,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;gBAC7B,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACJ,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAE,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACjH,CAAC;KACJ,CAAC;AACN,CAAC;AAID,MAAM,UAAU,QAAQ,CAAU,UAAgC;IAC9D,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function _reduce(callback, initialValue) {
|
|
2
|
+
let reduced;
|
|
3
|
+
return {
|
|
4
|
+
observe: (value, idx) => {
|
|
5
|
+
if (idx === 0) {
|
|
6
|
+
reduced = initialValue === undefined ? value : callback(initialValue, value, idx);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
reduced = callback(reduced, value, idx);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
peek: () => reduced
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function reduce(callbackFn, initialValue) {
|
|
16
|
+
return _reduce(callbackFn, initialValue);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reduce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduce.js","sourceRoot":"","sources":["../../src/observers/reduce.ts"],"names":[],"mappings":"AAIA,SAAS,OAAO,CAAO,QAA8B,EAAE,YAAgB;IACnE,IAAI,OAAU,CAAC;IAEf,OAAO;QACH,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAW,EAAE,EAAE;YAC/B,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;gBACZ,OAAO,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAE,KAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACxG,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO;KACtB,CAAC;AACN,CAAC;AAED,MAAM,UAAU,MAAM,CAAmB,UAAgC,EAAE,YAAgB;IACvF,OAAO,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Accessor } from "./observer";
|
|
2
|
+
function _variance() {
|
|
3
|
+
let count;
|
|
4
|
+
let mean;
|
|
5
|
+
let sum;
|
|
6
|
+
return {
|
|
7
|
+
observe: (value, idx) => {
|
|
8
|
+
if (idx === 0) {
|
|
9
|
+
count = 0;
|
|
10
|
+
mean = 0;
|
|
11
|
+
sum = 0;
|
|
12
|
+
}
|
|
13
|
+
const delta = value - mean;
|
|
14
|
+
mean += delta / ++count;
|
|
15
|
+
sum += delta * (value - mean);
|
|
16
|
+
},
|
|
17
|
+
peek: () => count > 1 ? sum / (count - 1) : undefined
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function variance(callbackFn) {
|
|
21
|
+
return callbackFn ? Accessor(_variance, callbackFn) : _variance();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=variance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variance.js","sourceRoot":"","sources":["../../src/observers/variance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3D,SAAS,SAAS;IACd,IAAI,KAAa,CAAC;IAClB,IAAI,IAAY,CAAC;IACjB,IAAI,GAAW,CAAC;IAEhB,OAAO;QACH,OAAO,EAAE,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;YACpC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;gBACZ,KAAK,GAAG,CAAC,CAAC;gBACV,IAAI,GAAG,CAAC,CAAC;gBACT,GAAG,GAAG,CAAC,CAAC;YACZ,CAAC;YACD,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;YAC3B,IAAI,IAAI,KAAK,GAAG,EAAE,KAAK,CAAC;YACxB,GAAG,IAAI,KAAK,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACxD,CAAC;AACN,CAAC;AAMD,MAAM,UAAU,QAAQ,CAAU,UAAgC;IAC9D,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/utils/generate.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAI,WAAoB,EAAE,MAAe;IAC9D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACX,OAAO,MAAM,KAAK,SAAS,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;QAC1C,MAAM,WAAW,EAAE,CAAC;IACxB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isSource } from "../activities/activity";
|
|
2
|
+
const GeneratorFunction = (function* () { }).constructor;
|
|
3
|
+
function chainGen(...items) {
|
|
4
|
+
if (items[items.length - 1] instanceof GeneratorFunction) {
|
|
5
|
+
return function* (source) {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
let tail = source;
|
|
8
|
+
for (const activity of items) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
tail = activity(tail);
|
|
11
|
+
}
|
|
12
|
+
yield* tail;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return function (source) {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
let tail = source;
|
|
19
|
+
for (const activity of items) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
tail = activity(tail);
|
|
22
|
+
}
|
|
23
|
+
return tail;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function pipe(s_or_ia, ...items) {
|
|
28
|
+
return isSource(s_or_ia) ? chainGen(...items)(s_or_ia) : chainGen(s_or_ia, ...items);
|
|
29
|
+
}
|
|
30
|
+
// Maintain backward compatibility
|
|
31
|
+
export const chain = pipe;
|
|
32
|
+
//# sourceMappingURL=pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../src/utils/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAkB,MAAM,wBAAwB,CAAC;AAE5F,MAAM,iBAAiB,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;AAEzD,SAAS,QAAQ,CAAO,GAAG,KAAgF;IACvG,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,YAAY,iBAAiB,EAAE,CAAC;QACvD,OAAO,QAAQ,CAAC,EAAE,MAAM;YACpB,aAAa;YACb,IAAI,IAAI,GAAwB,MAAM,CAAC;YACvC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC3B,aAAa;gBACb,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YACD,KAAK,CAAC,CAAC,IAAI,CAAC;QAChB,CAAC,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,OAAO,UAAU,MAAM;YACnB,aAAa;YACb,IAAI,IAAI,GAAwB,MAAM,CAAC;YACvC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC3B,aAAa;gBACb,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;IACN,CAAC;AACL,CAAC;AA0CD,MAAM,UAAU,IAAI,CAAa,OAA2C,EAAE,GAAG,KAAgF;IAC7J,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAO,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,mCAAmC;AACnC,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,42 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/dataflow",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.1",
|
|
4
4
|
"description": "hpcc-js - Data Flow",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "lib-es6/index",
|
|
7
|
+
"unpkg": "dist/index.min.js",
|
|
8
|
+
"jsdelivr": "dist/index.min.js",
|
|
9
|
+
"types": "types/index.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
"<3.8": {
|
|
12
|
+
"*": [
|
|
13
|
+
"types-3.4/index.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
12
16
|
},
|
|
13
|
-
"main": "./dist/index.js",
|
|
14
|
-
"types": "./types/index.d.ts",
|
|
15
17
|
"files": [
|
|
16
18
|
"dist/*",
|
|
17
|
-
"
|
|
18
|
-
"types/*"
|
|
19
|
+
"types/*",
|
|
20
|
+
"types-3.4/*",
|
|
21
|
+
"lib-es6/*",
|
|
22
|
+
"src/*"
|
|
19
23
|
],
|
|
20
24
|
"scripts": {
|
|
21
|
-
"clean": "rimraf --glob lib* types dist
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"clean": "rimraf --glob lib* types dist* *.tsbuildinfo",
|
|
26
|
+
"compile-es6": "tsc --module es6 --outDir ./lib-es6",
|
|
27
|
+
"compile-es6-watch": "npm run compile-es6 -- -w",
|
|
28
|
+
"compile-umd": "tsc --module umd --outDir ./lib-umd",
|
|
29
|
+
"compile-umd-watch": "npm run compile-umd -- -w",
|
|
30
|
+
"bundle": "rollup -c",
|
|
31
|
+
"bundle-watch": "npm run bundle -- -w",
|
|
32
|
+
"bundle-test": "rollup -c ./rollup-test.config.mjs",
|
|
33
|
+
"bundle-test-watch": "npm run bundle-test -- -w",
|
|
34
|
+
"minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js",
|
|
35
|
+
"gen-legacy-types": "downlevel-dts ./types ./types-3.4",
|
|
36
|
+
"build": "npm-run-all -p compile-es6 compile-umd -s bundle",
|
|
37
|
+
"watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
|
|
38
|
+
"stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
|
|
27
39
|
"lint": "eslint ./src",
|
|
40
|
+
"lint-fix": "eslint --fix src/**/*.ts",
|
|
41
|
+
"test": "mocha dist-test/index.js --reporter spec",
|
|
28
42
|
"docs": "typedoc --options tdoptions.json .",
|
|
29
|
-
"
|
|
30
|
-
"test-node": "vitest run --project node",
|
|
31
|
-
"test": "vitest run",
|
|
32
|
-
"coverage": "vitest run --coverage",
|
|
33
|
-
"update": "npx -y npm-check-updates -u -t minor",
|
|
34
|
-
"update-major": "npx -y npm-check-updates -u"
|
|
43
|
+
"update": "npx --yes npm-check-updates -u -t minor"
|
|
35
44
|
},
|
|
36
45
|
"devDependencies": {
|
|
37
|
-
"@hpcc-js/
|
|
46
|
+
"@hpcc-js/bundle": "^2.12.0",
|
|
38
47
|
"@types/faker": "4.1.12",
|
|
39
|
-
"@types/
|
|
48
|
+
"@types/mocha": "10.0.10",
|
|
40
49
|
"faker": "4.1.0"
|
|
41
50
|
},
|
|
42
51
|
"repository": {
|
|
@@ -49,6 +58,6 @@
|
|
|
49
58
|
"bugs": {
|
|
50
59
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
51
60
|
},
|
|
52
|
-
"homepage": "https://github.com/hpcc-systems/Visualization
|
|
53
|
-
"gitHead": "
|
|
61
|
+
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
62
|
+
"gitHead": "0907b8d15d369c89483954a1d96e2247ba020cb6"
|
|
54
63
|
}
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PKG_NAME = "@hpcc-js/dataflow";
|
|
2
|
-
export const PKG_VERSION = "9.2.0";
|
|
3
|
-
export const BUILD_VERSION = "
|
|
1
|
+
export const PKG_NAME = "@hpcc-js/dataflow";
|
|
2
|
+
export const PKG_VERSION = "9.2.0";
|
|
3
|
+
export const BUILD_VERSION = "2.108.6";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { count } from "../observers/count";
|
|
3
|
+
import { concat, pipe, filter, min, max, map, each, generate, sensor, scalar, activity } from "../index";
|
|
4
|
+
import { person, Person, population } from "./data";
|
|
5
|
+
|
|
6
|
+
describe("chain", () => {
|
|
7
|
+
it("generator", () => {
|
|
8
|
+
const p = pipe(concat([3, 4, 5, 6]), concat([7, 8]));
|
|
9
|
+
expect([...p([1, 2])]).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
10
|
+
const p2 = pipe(concat([3, 4, 5, 6]), filter(i => i % 2 === 0), concat([7, 8]));
|
|
11
|
+
expect([...p2([1, 2])]).to.deep.equal([2, 4, 6, 7, 8]);
|
|
12
|
+
const p3 = pipe(concat([3, 4, 5, 6]), filter(i => i % 2 === 0), concat([7, 8]), filter(i => i % 2 === 0));
|
|
13
|
+
expect([...p3([1, 2])]).to.deep.equal([2, 4, 6, 8]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("fn", () => {
|
|
17
|
+
expect([...pipe([1, 2])]).to.deep.equal([1, 2]);
|
|
18
|
+
const p = pipe([1, 2], concat([3, 4, 5, 6]), concat([7, 8]));
|
|
19
|
+
expect([...p]).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
20
|
+
const p2 = pipe([1, 2], concat([3, 4, 5, 6]), filter(i => i % 2 === 0), concat([7, 8]));
|
|
21
|
+
expect([...p2]).to.deep.equal([2, 4, 6, 7, 8]);
|
|
22
|
+
const p3 = pipe([1, 2], concat([3, 4, 5, 6]), filter(i => i % 2 === 0), concat([7, 8]), filter(i => i % 2 === 0));
|
|
23
|
+
expect([...p3]).to.deep.equal([2, 4, 6, 8]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("activity", () => {
|
|
27
|
+
expect([...pipe(
|
|
28
|
+
concat([3, 4, 5, 6]),
|
|
29
|
+
concat([7, 8]),
|
|
30
|
+
activity(max())
|
|
31
|
+
)([1, 2])]).to.deep.equal([8]);
|
|
32
|
+
|
|
33
|
+
expect([...pipe(
|
|
34
|
+
[1, 2],
|
|
35
|
+
concat([3, 4, 5, 6]),
|
|
36
|
+
concat([7, -1, 8]),
|
|
37
|
+
activity(min())
|
|
38
|
+
)]).to.deep.equal([-1]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("scalar", () => {
|
|
42
|
+
expect(pipe(
|
|
43
|
+
concat([3, 4, 5, 6]),
|
|
44
|
+
concat([7, 8]),
|
|
45
|
+
scalar(max())
|
|
46
|
+
)([1, 2])).to.equal(8);
|
|
47
|
+
|
|
48
|
+
expect(pipe(
|
|
49
|
+
[1, 2],
|
|
50
|
+
concat([3, 4, 5, 6]),
|
|
51
|
+
concat([7, -1, 8]),
|
|
52
|
+
scalar(min())
|
|
53
|
+
)).to.equal(-1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("chain-all", () => {
|
|
57
|
+
const s1 = count();
|
|
58
|
+
const s2 = count();
|
|
59
|
+
const myPipeline = pipe(
|
|
60
|
+
map((_: Person) => ({ id: _.email, display: `The id is: ${_}`, ageBucket: Math.round(_.age / 10) })),
|
|
61
|
+
each(row => { /* do nothing */ }),
|
|
62
|
+
sensor(s1),
|
|
63
|
+
filter(_ => _.ageBucket !== 2),
|
|
64
|
+
sensor(s2)
|
|
65
|
+
);
|
|
66
|
+
expect([...myPipeline(generate(person, 1000))]).to.have.lengthOf(829);
|
|
67
|
+
expect(s1.peek()).to.equal(1000);
|
|
68
|
+
expect(s2.peek()).to.equal(829);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("sensor", () => {
|
|
72
|
+
const s1 = max(r => r.age);
|
|
73
|
+
const s2 = max(r => r.age);
|
|
74
|
+
const p1 = pipe(
|
|
75
|
+
sensor(s1),
|
|
76
|
+
filter(r => r.age < 30),
|
|
77
|
+
sensor(s2),
|
|
78
|
+
);
|
|
79
|
+
const data = [...p1(population)];
|
|
80
|
+
expect(data.length).to.equal(286);
|
|
81
|
+
expect(s1.peek()).to.equal(66);
|
|
82
|
+
expect(s2.peek()).to.equal(29);
|
|
83
|
+
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { concat } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("concat", () => {
|
|
5
|
+
it("generator", () => {
|
|
6
|
+
expect([...concat([])([])]).to.deep.equal([]);
|
|
7
|
+
expect([...concat([1, 2, 3])([])]).to.deep.equal([1, 2, 3]);
|
|
8
|
+
expect([...concat<number>([])([1, 2, 3])]).to.deep.equal([1, 2, 3]);
|
|
9
|
+
expect([...concat([4, 5, 6])([1, 2, 3])]).to.deep.equal([1, 2, 3, 4, 5, 6]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("scalarActivity", () => {
|
|
13
|
+
expect([...concat([], [])]).to.deep.equal([]);
|
|
14
|
+
expect([...concat([], [1, 2, 3])]).to.deep.equal([1, 2, 3]);
|
|
15
|
+
expect([...concat([1, 2, 3], [])]).to.deep.equal([1, 2, 3]);
|
|
16
|
+
expect([...concat([1, 2, 3], [4, 5, 6])]).to.deep.equal([1, 2, 3, 4, 5, 6]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { pipe, filter, count, scalar, sensor } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("count", () => {
|
|
6
|
+
|
|
7
|
+
it("Population", () => {
|
|
8
|
+
const s1 = count();
|
|
9
|
+
const s2 = count();
|
|
10
|
+
const p1 = pipe(
|
|
11
|
+
sensor(s1),
|
|
12
|
+
filter(r => r.age > 30),
|
|
13
|
+
sensor(s2),
|
|
14
|
+
);
|
|
15
|
+
const data = [...p1(population)];
|
|
16
|
+
expect(s1.peek()).to.equal(1000);
|
|
17
|
+
expect(s2.peek()).to.equal(699);
|
|
18
|
+
expect(data.length).to.equal(699);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("scalarActivity", () => {
|
|
22
|
+
const countActivity = scalar(count());
|
|
23
|
+
expect(countActivity([5, 1, 2, -3, 4])).to.equal(5);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as faker from "faker";
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
|
|
4
|
+
faker.seed(123);
|
|
5
|
+
|
|
6
|
+
export function person() {
|
|
7
|
+
return {
|
|
8
|
+
"fname": faker.name.firstName(),
|
|
9
|
+
"lname": faker.name.lastName(),
|
|
10
|
+
"age": faker.random.number(50) + 16,
|
|
11
|
+
"job": faker.name.jobType(),
|
|
12
|
+
"username": faker.internet.userName(),
|
|
13
|
+
"email": faker.internet.email(),
|
|
14
|
+
"address": {
|
|
15
|
+
"street": faker.address.streetName(),
|
|
16
|
+
"suite": faker.address.secondaryAddress(),
|
|
17
|
+
"city": faker.address.city(),
|
|
18
|
+
"zipcode": faker.address.zipCode(),
|
|
19
|
+
"state": faker.address.stateAbbr(),
|
|
20
|
+
"geo": {
|
|
21
|
+
"lat": faker.address.latitude(),
|
|
22
|
+
"lng": faker.address.longitude()
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"phone": faker.phone.phoneNumber(),
|
|
26
|
+
"website": faker.internet.domainName(),
|
|
27
|
+
"company": {
|
|
28
|
+
"name": faker.company.companyName(),
|
|
29
|
+
"catchPhrase": faker.company.catchPhrase(),
|
|
30
|
+
"bs": faker.company.bs()
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type Person = ReturnType<typeof person>;
|
|
35
|
+
|
|
36
|
+
export function* people(total = 1000) {
|
|
37
|
+
for (let i = 0; i < total; ++i) {
|
|
38
|
+
yield person();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function personLite() {
|
|
43
|
+
return {
|
|
44
|
+
"fname": faker.name.firstName(),
|
|
45
|
+
"lname": faker.name.lastName(),
|
|
46
|
+
"zipcode": faker.address.zipCode(),
|
|
47
|
+
"state": faker.address.stateAbbr()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type PersonLite = ReturnType<typeof person>;
|
|
51
|
+
|
|
52
|
+
export function* peopleLite(total = 1000) {
|
|
53
|
+
for (let i = 0; i < total; ++i) {
|
|
54
|
+
yield personLite();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const population: Person[] = [...people()];
|
|
59
|
+
|
|
60
|
+
describe("data", () => {
|
|
61
|
+
it("generate", () => {
|
|
62
|
+
expect(population).to.have.lengthOf(1000);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { deviation, scalar } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("deviation", () => {
|
|
5
|
+
it("scalarActivity", () => {
|
|
6
|
+
const calcDeviation = scalar(deviation());
|
|
7
|
+
expect(calcDeviation([5, 1, 2, 3, 4])).to.equal(Math.sqrt(2.5));
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("empty array", () => {
|
|
11
|
+
const deviationActivity = scalar(deviation());
|
|
12
|
+
expect(deviationActivity([])).to.be.undefined;
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { distribution, scalar } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("distribution", () => {
|
|
5
|
+
|
|
6
|
+
it("scalarActivity", () => {
|
|
7
|
+
const calcDistribution = scalar(distribution());
|
|
8
|
+
expect(calcDistribution([5, 1, 2, 3, 4])).to.deep.equal({
|
|
9
|
+
min: 1,
|
|
10
|
+
mean: 3,
|
|
11
|
+
max: 5,
|
|
12
|
+
deviation: Math.sqrt(2.5),
|
|
13
|
+
variance: 2.5
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("empty array", () => {
|
|
18
|
+
const a1 = scalar(distribution());
|
|
19
|
+
expect(a1([])).to.be.undefined;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { each } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("each", () => {
|
|
6
|
+
it("generator", () => {
|
|
7
|
+
[...each((row, i) => expect(row).to.equal(population[i]))(population)];
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("scalarActivity", () => {
|
|
11
|
+
[...each(population, (row, i) => expect(row).to.equal(population[i]))];
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { entries } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("entries", () => {
|
|
5
|
+
it("generator", () => {
|
|
6
|
+
expect([...entries()([])]).to.deep.equal([]);
|
|
7
|
+
expect([...entries()(["a", "b", "c"])]).to.deep.equal([[0, "a"], [1, "b"], [2, "c"]]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("scalarActivity", () => {
|
|
11
|
+
expect([...entries([])]).to.deep.equal([]);
|
|
12
|
+
expect([...entries(["a", "b", "c"])]).to.deep.equal([[0, "a"], [1, "b"], [2, "c"]]);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { pipe, filter, extent, scalar, sensor } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("max", () => {
|
|
6
|
+
|
|
7
|
+
it("Population", () => {
|
|
8
|
+
const s1 = extent(r => r.age);
|
|
9
|
+
const s2 = extent(r => r.age);
|
|
10
|
+
const p1 = pipe(
|
|
11
|
+
sensor(s1),
|
|
12
|
+
filter(r => r.age > 30),
|
|
13
|
+
sensor(s2),
|
|
14
|
+
);
|
|
15
|
+
const data = [...p1(population)];
|
|
16
|
+
expect(data.length).to.equal(699);
|
|
17
|
+
expect(s1.peek()).to.deep.equal([16, 66]);
|
|
18
|
+
expect(s2.peek()).to.deep.equal([31, 66]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("scalarActivity", () => {
|
|
22
|
+
const extentActivity = scalar(extent());
|
|
23
|
+
expect(extentActivity([5, 1, 2, -3, 4])).to.deep.equal([-3, 5]);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { filter } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
const testFilter = row => row.address.state === "FL";
|
|
6
|
+
const expected = population.filter(testFilter);
|
|
7
|
+
|
|
8
|
+
describe("filter", () => {
|
|
9
|
+
it("generator", () => {
|
|
10
|
+
expect([...filter(testFilter)(population)]).to.deep.equal(expected);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("scalarActivity", () => {
|
|
14
|
+
expect([...filter(population, testFilter)]).to.deep.equal(expected);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { first } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("first", () => {
|
|
5
|
+
it("generator", () => {
|
|
6
|
+
expect([...first(2)([])]).to.deep.equal([]);
|
|
7
|
+
expect([...first(2)(["a", "b", "c"])]).to.deep.equal(["a", "b"]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("scalarActivity", () => {
|
|
11
|
+
expect([...first([], 22)]).to.deep.equal([]);
|
|
12
|
+
expect([...first(["a", "b", "c"], 2)]).to.deep.equal(["a", "b"]);
|
|
13
|
+
expect([...first(["a", "b", "c"], 22)]).to.deep.equal(["a", "b", "c"]);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { group } from "../index";
|
|
3
|
+
import { Person, population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("group", () => {
|
|
6
|
+
it("generator", () => {
|
|
7
|
+
const gb = [...group<Person>(row => row.address.state)(population)];
|
|
8
|
+
expect(gb).to.have.length;
|
|
9
|
+
expect(gb[0].key).to.exist;
|
|
10
|
+
expect(gb[0].value).to.have.length;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("scalarActivity", () => {
|
|
14
|
+
const gb = [...group(population, row => row.address.state)];
|
|
15
|
+
expect(gb).to.have.length;
|
|
16
|
+
expect(gb[0].key).to.exist;
|
|
17
|
+
expect(gb[0].value).to.have.length;
|
|
18
|
+
});
|
|
19
|
+
});
|