@hpcc-js/dataflow 8.1.1 → 8.1.2
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 +443 -443
- package/dist/index.js.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib-es6/__package__.js +3 -3
- package/lib-es6/__package__.js.map +1 -1
- package/lib-es6/__tests__/chain.js +48 -48
- package/lib-es6/__tests__/concat.js +16 -16
- package/lib-es6/__tests__/count.js +18 -18
- package/lib-es6/__tests__/data.js +55 -55
- package/lib-es6/__tests__/deviation.js +12 -12
- package/lib-es6/__tests__/distribution.js +18 -18
- package/lib-es6/__tests__/each.js +11 -11
- package/lib-es6/__tests__/entries.js +12 -12
- package/lib-es6/__tests__/extent.js +18 -18
- package/lib-es6/__tests__/filter.js +13 -13
- package/lib-es6/__tests__/first.js +13 -13
- package/lib-es6/__tests__/generate.js +7 -7
- package/lib-es6/__tests__/group.js +17 -17
- package/lib-es6/__tests__/histogram.js +41 -41
- package/lib-es6/__tests__/map.js +13 -13
- package/lib-es6/__tests__/max.js +29 -29
- package/lib-es6/__tests__/mean.js +9 -9
- package/lib-es6/__tests__/median.js +12 -12
- package/lib-es6/__tests__/min.js +29 -29
- package/lib-es6/__tests__/quartile.js +11 -11
- package/lib-es6/__tests__/readme.js +95 -95
- package/lib-es6/__tests__/readme.js.map +1 -1
- package/lib-es6/__tests__/reduce.js +14 -14
- package/lib-es6/__tests__/skip.js +13 -13
- package/lib-es6/__tests__/sort.js +18 -18
- package/lib-es6/__tests__/variance.js +12 -12
- package/lib-es6/activities/activity.js +3 -3
- package/lib-es6/activities/concat.js +9 -9
- package/lib-es6/activities/each.js +13 -13
- package/lib-es6/activities/entries.js +12 -12
- package/lib-es6/activities/filter.js +14 -14
- package/lib-es6/activities/first.js +17 -17
- package/lib-es6/activities/group.js +20 -20
- package/lib-es6/activities/histogram.js +63 -63
- package/lib-es6/activities/map.js +12 -12
- package/lib-es6/activities/skip.js +16 -16
- package/lib-es6/activities/sort.js +9 -9
- package/lib-es6/index.js +25 -25
- package/lib-es6/observers/count.js +12 -12
- package/lib-es6/observers/deviation.js +17 -17
- package/lib-es6/observers/distribution.js +35 -35
- package/lib-es6/observers/extent.js +17 -17
- package/lib-es6/observers/max.js +18 -18
- package/lib-es6/observers/mean.js +20 -20
- package/lib-es6/observers/median.js +25 -25
- package/lib-es6/observers/min.js +18 -18
- package/lib-es6/observers/observer.js +34 -34
- package/lib-es6/observers/quartile.js +37 -37
- package/lib-es6/observers/reduce.js +17 -17
- package/lib-es6/observers/variance.js +22 -22
- package/lib-es6/utils/generate.js +6 -6
- package/lib-es6/utils/pipe.js +31 -31
- package/package.json +3 -3
- package/src/__package__.ts +3 -3
- package/src/__tests__/chain.ts +85 -85
- package/src/__tests__/concat.ts +18 -18
- package/src/__tests__/count.ts +25 -25
- package/src/__tests__/data.ts +64 -64
- package/src/__tests__/deviation.ts +14 -14
- package/src/__tests__/distribution.ts +21 -21
- package/src/__tests__/each.ts +13 -13
- package/src/__tests__/entries.ts +14 -14
- package/src/__tests__/extent.ts +25 -25
- package/src/__tests__/filter.ts +16 -16
- package/src/__tests__/first.ts +15 -15
- package/src/__tests__/generate.ts +9 -9
- package/src/__tests__/group.ts +19 -19
- package/src/__tests__/histogram.ts +47 -47
- package/src/__tests__/map.ts +16 -16
- package/src/__tests__/max.ts +42 -42
- package/src/__tests__/mean.ts +11 -11
- package/src/__tests__/median.ts +14 -14
- package/src/__tests__/min.ts +42 -42
- package/src/__tests__/quartile.ts +14 -14
- package/src/__tests__/readme.ts +113 -113
- package/src/__tests__/reduce.ts +17 -17
- package/src/__tests__/skip.ts +15 -15
- package/src/__tests__/sort.ts +21 -21
- package/src/__tests__/variance.ts +14 -14
- 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/map.ts +18 -18
- package/src/activities/skip.ts +19 -19
- package/src/activities/sort.ts +16 -16
- package/src/index.ts +25 -25
- 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 +3 -3
- package/types/__package__.d.ts.map +1 -1
- package/types/__tests__/chain.d.ts +1 -1
- package/types/__tests__/concat.d.ts +1 -1
- package/types/__tests__/count.d.ts +1 -1
- package/types/__tests__/data.d.ts +61 -61
- package/types/__tests__/deviation.d.ts +1 -1
- package/types/__tests__/distribution.d.ts +1 -1
- package/types/__tests__/each.d.ts +1 -1
- package/types/__tests__/entries.d.ts +1 -1
- package/types/__tests__/extent.d.ts +1 -1
- package/types/__tests__/filter.d.ts +1 -1
- package/types/__tests__/first.d.ts +1 -1
- package/types/__tests__/generate.d.ts +1 -1
- package/types/__tests__/group.d.ts +1 -1
- package/types/__tests__/histogram.d.ts +1 -1
- package/types/__tests__/map.d.ts +1 -1
- package/types/__tests__/max.d.ts +1 -1
- package/types/__tests__/mean.d.ts +1 -1
- package/types/__tests__/median.d.ts +1 -1
- package/types/__tests__/min.d.ts +1 -1
- package/types/__tests__/quartile.d.ts +1 -1
- package/types/__tests__/readme.d.ts +1 -1
- package/types/__tests__/reduce.d.ts +1 -1
- package/types/__tests__/skip.d.ts +1 -1
- package/types/__tests__/sort.d.ts +1 -1
- package/types/__tests__/variance.d.ts +1 -1
- package/types/activities/activity.d.ts +5 -5
- package/types/activities/concat.d.ts +3 -3
- package/types/activities/each.d.ts +4 -4
- package/types/activities/entries.d.ts +3 -3
- package/types/activities/filter.d.ts +4 -4
- package/types/activities/first.d.ts +3 -3
- package/types/activities/group.d.ts +8 -8
- package/types/activities/histogram.d.ts +17 -17
- package/types/activities/map.d.ts +4 -4
- package/types/activities/skip.d.ts +3 -3
- package/types/activities/sort.d.ts +4 -4
- package/types/index.d.ts +25 -25
- package/types/observers/count.d.ts +2 -2
- package/types/observers/deviation.d.ts +4 -4
- package/types/observers/distribution.d.ts +12 -12
- package/types/observers/extent.d.ts +4 -4
- package/types/observers/max.d.ts +4 -4
- package/types/observers/mean.d.ts +4 -4
- package/types/observers/median.d.ts +4 -4
- package/types/observers/min.d.ts +4 -4
- package/types/observers/observer.d.ts +13 -13
- package/types/observers/quartile.d.ts +5 -5
- package/types/observers/reduce.d.ts +3 -3
- package/types/observers/variance.d.ts +4 -4
- package/types/utils/generate.d.ts +1 -1
- package/types/utils/pipe.d.ts +41 -41
- package/types-3.4/__package__.d.ts +2 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { median, scalar } from "../index";
|
|
3
|
-
describe("median", () => {
|
|
4
|
-
it("scalarActivity", () => {
|
|
5
|
-
const calcMedian = scalar(median());
|
|
6
|
-
expect(calcMedian([-6, -2, 1, 2, 5])).to.equal(1);
|
|
7
|
-
expect(calcMedian([5, -6, 1, 2, -2])).to.equal(1);
|
|
8
|
-
expect(calcMedian([-6, -2, 1, 2, 5, 6])).to.equal(1.5);
|
|
9
|
-
expect(calcMedian([5, -6, 1, 2, -2, 6])).to.equal(1.5);
|
|
10
|
-
expect(calcMedian([9])).to.deep.equal(9);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { median, scalar } from "../index";
|
|
3
|
+
describe("median", () => {
|
|
4
|
+
it("scalarActivity", () => {
|
|
5
|
+
const calcMedian = scalar(median());
|
|
6
|
+
expect(calcMedian([-6, -2, 1, 2, 5])).to.equal(1);
|
|
7
|
+
expect(calcMedian([5, -6, 1, 2, -2])).to.equal(1);
|
|
8
|
+
expect(calcMedian([-6, -2, 1, 2, 5, 6])).to.equal(1.5);
|
|
9
|
+
expect(calcMedian([5, -6, 1, 2, -2, 6])).to.equal(1.5);
|
|
10
|
+
expect(calcMedian([9])).to.deep.equal(9);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
13
|
//# sourceMappingURL=median.js.map
|
package/lib-es6/__tests__/min.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { pipe, filter, min, scalar, sensor } from "../index";
|
|
3
|
-
import { population } from "./data";
|
|
4
|
-
describe("min", () => {
|
|
5
|
-
it("NumberArray", () => {
|
|
6
|
-
const s1 = min();
|
|
7
|
-
const s2 = min();
|
|
8
|
-
const p1 = pipe(sensor(s1), filter(r => r > 3), sensor(s2));
|
|
9
|
-
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
10
|
-
expect(data.length).to.equal(2);
|
|
11
|
-
expect(s1.peek()).to.equal(0);
|
|
12
|
-
expect(s2.peek()).to.equal(4);
|
|
13
|
-
});
|
|
14
|
-
it("Population", () => {
|
|
15
|
-
const s1 = min(r => r.age);
|
|
16
|
-
const s2 = min(r => r.age);
|
|
17
|
-
const p1 = pipe(sensor(s1), filter(r => r.age > 30), sensor(s2));
|
|
18
|
-
const data = [...p1(population)];
|
|
19
|
-
expect(data.length).to.equal(699);
|
|
20
|
-
expect(s1.peek()).to.equal(16);
|
|
21
|
-
expect(s2.peek()).to.equal(31);
|
|
22
|
-
});
|
|
23
|
-
it("scalarActivity", () => {
|
|
24
|
-
const a1 = scalar(min());
|
|
25
|
-
expect(a1([1, 2, 3, 4, 5, 0])).to.equal(0);
|
|
26
|
-
const a2 = scalar(min(r => r.age));
|
|
27
|
-
expect(a2(population)).to.equal(16);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { pipe, filter, min, scalar, sensor } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
describe("min", () => {
|
|
5
|
+
it("NumberArray", () => {
|
|
6
|
+
const s1 = min();
|
|
7
|
+
const s2 = min();
|
|
8
|
+
const p1 = pipe(sensor(s1), filter(r => r > 3), sensor(s2));
|
|
9
|
+
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
10
|
+
expect(data.length).to.equal(2);
|
|
11
|
+
expect(s1.peek()).to.equal(0);
|
|
12
|
+
expect(s2.peek()).to.equal(4);
|
|
13
|
+
});
|
|
14
|
+
it("Population", () => {
|
|
15
|
+
const s1 = min(r => r.age);
|
|
16
|
+
const s2 = min(r => r.age);
|
|
17
|
+
const p1 = pipe(sensor(s1), filter(r => r.age > 30), sensor(s2));
|
|
18
|
+
const data = [...p1(population)];
|
|
19
|
+
expect(data.length).to.equal(699);
|
|
20
|
+
expect(s1.peek()).to.equal(16);
|
|
21
|
+
expect(s2.peek()).to.equal(31);
|
|
22
|
+
});
|
|
23
|
+
it("scalarActivity", () => {
|
|
24
|
+
const a1 = scalar(min());
|
|
25
|
+
expect(a1([1, 2, 3, 4, 5, 0])).to.equal(0);
|
|
26
|
+
const a2 = scalar(min(r => r.age));
|
|
27
|
+
expect(a2(population)).to.equal(16);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
30
|
//# sourceMappingURL=min.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { quartile, scalar } from "../index";
|
|
3
|
-
describe("quartile", () => {
|
|
4
|
-
it("scalarActivity", () => {
|
|
5
|
-
const calcQuartile = scalar(quartile());
|
|
6
|
-
expect(calcQuartile([6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49])).to.deep.equal([6, 15, 40, 43, 49]);
|
|
7
|
-
expect(calcQuartile([7, 15, 36, 39, 40, 41])).to.deep.equal([7, 15, 37.5, 40, 41]);
|
|
8
|
-
expect(calcQuartile([1, 22, 133])).to.deep.equal([1, 1, 22, 133, 133]);
|
|
9
|
-
expect(calcQuartile([2, 144, 33])).to.deep.equal([2, 2, 33, 144, 144]);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { quartile, scalar } from "../index";
|
|
3
|
+
describe("quartile", () => {
|
|
4
|
+
it("scalarActivity", () => {
|
|
5
|
+
const calcQuartile = scalar(quartile());
|
|
6
|
+
expect(calcQuartile([6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49])).to.deep.equal([6, 15, 40, 43, 49]);
|
|
7
|
+
expect(calcQuartile([7, 15, 36, 39, 40, 41])).to.deep.equal([7, 15, 37.5, 40, 41]);
|
|
8
|
+
expect(calcQuartile([1, 22, 133])).to.deep.equal([1, 1, 22, 133, 133]);
|
|
9
|
+
expect(calcQuartile([2, 144, 33])).to.deep.equal([2, 2, 33, 144, 144]);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
12
|
//# sourceMappingURL=quartile.js.map
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { count, filter, first, generate, map, max, pipe, sensor } from "../index";
|
|
3
|
-
describe("readme", () => {
|
|
4
|
-
it("quick example", () => {
|
|
5
|
-
const c1 = count();
|
|
6
|
-
const c2 = count();
|
|
7
|
-
const c3 = count();
|
|
8
|
-
const m1 = max(row => row.value);
|
|
9
|
-
const p1 = pipe(sensor(c1), // Keep running count of input
|
|
10
|
-
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
11
|
-
sensor(c2), // Keep running count of filtered rows
|
|
12
|
-
map((n, idx) => // Convert to JSON Object
|
|
13
|
-
({ index: idx, value: n })), filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
14
|
-
sensor(c3), // Keep running count of final rows
|
|
15
|
-
sensor(m1), // Track largest value
|
|
16
|
-
first(3) // Take first 3 rows
|
|
17
|
-
);
|
|
18
|
-
console.
|
|
19
|
-
// [1] => Counts: undefined, undefined, undefined
|
|
20
|
-
const outIterable = p1(generate(Math.random, 1000));
|
|
21
|
-
console.
|
|
22
|
-
// [2] => Counts: undefined, undefined, undefined
|
|
23
|
-
console.
|
|
24
|
-
// [3] => [{"index":0,"value":0.19075931906641008},{"index":2,"value":0.4873469062925415},{"index":4,"value":0.4412516774100035}]
|
|
25
|
-
console.
|
|
26
|
-
// [4] => Counts: 6, 5, 3, 0.4873469062925415
|
|
27
|
-
const outArray = [...p1([0.7, 0.5, 0.4, 0.8, 0.3, 1])];
|
|
28
|
-
console.
|
|
29
|
-
// [5] => [{"index":0,"value":0.5},{"index":2,"value":0.3}]
|
|
30
|
-
console.
|
|
31
|
-
// [6] => Counts: 6, 3, 2, 0.5
|
|
32
|
-
expect(outArray.length).to.equal(2);
|
|
33
|
-
for (const row of p1(generate(Math.random, 1000000))) {
|
|
34
|
-
console.
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
it("interesting example", () => {
|
|
38
|
-
const c1 = count();
|
|
39
|
-
const c2 = count();
|
|
40
|
-
const c3 = count();
|
|
41
|
-
const m1 = max(row => row.value);
|
|
42
|
-
const p1 = pipe(sensor(c1), // Keep running count of input
|
|
43
|
-
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
44
|
-
sensor(c2), // Keep running count of filtered rows
|
|
45
|
-
map((n, idx) => // Convert to JSON Object
|
|
46
|
-
({ index: idx, value: n })), filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
47
|
-
sensor(c3), // Keep running count of final rows
|
|
48
|
-
sensor(m1));
|
|
49
|
-
for (const row of p1(generate(Math.random, 1000000))) {
|
|
50
|
-
if (row.index % 100000 === 0) {
|
|
51
|
-
console.
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
/*
|
|
57
|
-
const process3 = pipe(
|
|
58
|
-
filter(n => n <= 0.5),
|
|
59
|
-
map((n, idx) => ({ index: idx, value: n })),
|
|
60
|
-
filter(row => row.index % 2 === 0),
|
|
61
|
-
sort((l, r) => l.value - r.value),
|
|
62
|
-
first(3)
|
|
63
|
-
);
|
|
64
|
-
console.log(...process3([]));
|
|
65
|
-
|
|
66
|
-
// Iterable output
|
|
67
|
-
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
68
|
-
filter(n => n <= 5),
|
|
69
|
-
map((n, idx) => ({ index: idx, value: n })),
|
|
70
|
-
filter(row => row.index % 2 === 0),
|
|
71
|
-
sort((l, r) => l.value - r.value),
|
|
72
|
-
first(3)
|
|
73
|
-
); // => { index: 0, value: 0 }, { index: 2, value: 2 }, { index: 4, value: 4 }
|
|
74
|
-
|
|
75
|
-
const process = pipe(
|
|
76
|
-
filter(n => n <= 5),
|
|
77
|
-
map((n, idx) => ({ index: idx, value: n })),
|
|
78
|
-
filter(row => row.index % 2 === 0),
|
|
79
|
-
sort((l, r) => l.value - r.value),
|
|
80
|
-
first(3)
|
|
81
|
-
);
|
|
82
|
-
console.log([...process([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]); // => { index: 0, value: 0 }, { index: 2, value: 2 }, { index: 4, value: 4 }
|
|
83
|
-
|
|
84
|
-
// Scalar output
|
|
85
|
-
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
86
|
-
process,
|
|
87
|
-
scalar(max(row => row.value))
|
|
88
|
-
); // => 4
|
|
89
|
-
|
|
90
|
-
const process_2 = pipe(
|
|
91
|
-
process,
|
|
92
|
-
scalar(min(row => row.value))
|
|
93
|
-
);
|
|
94
|
-
console.log(process_2([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); // => 0
|
|
95
|
-
*/
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { count, filter, first, generate, map, max, pipe, sensor } from "../index";
|
|
3
|
+
describe("readme", () => {
|
|
4
|
+
it("quick example", () => {
|
|
5
|
+
const c1 = count();
|
|
6
|
+
const c2 = count();
|
|
7
|
+
const c3 = count();
|
|
8
|
+
const m1 = max(row => row.value);
|
|
9
|
+
const p1 = pipe(sensor(c1), // Keep running count of input
|
|
10
|
+
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
11
|
+
sensor(c2), // Keep running count of filtered rows
|
|
12
|
+
map((n, idx) => // Convert to JSON Object
|
|
13
|
+
({ index: idx, value: n })), filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
14
|
+
sensor(c3), // Keep running count of final rows
|
|
15
|
+
sensor(m1), // Track largest value
|
|
16
|
+
first(3) // Take first 3 rows
|
|
17
|
+
);
|
|
18
|
+
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}`);
|
|
19
|
+
// [1] => Counts: undefined, undefined, undefined
|
|
20
|
+
const outIterable = p1(generate(Math.random, 1000));
|
|
21
|
+
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}`);
|
|
22
|
+
// [2] => Counts: undefined, undefined, undefined
|
|
23
|
+
console.info(JSON.stringify([...outIterable]));
|
|
24
|
+
// [3] => [{"index":0,"value":0.19075931906641008},{"index":2,"value":0.4873469062925415},{"index":4,"value":0.4412516774100035}]
|
|
25
|
+
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
26
|
+
// [4] => Counts: 6, 5, 3, 0.4873469062925415
|
|
27
|
+
const outArray = [...p1([0.7, 0.5, 0.4, 0.8, 0.3, 1])];
|
|
28
|
+
console.info(JSON.stringify(outArray));
|
|
29
|
+
// [5] => [{"index":0,"value":0.5},{"index":2,"value":0.3}]
|
|
30
|
+
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
31
|
+
// [6] => Counts: 6, 3, 2, 0.5
|
|
32
|
+
expect(outArray.length).to.equal(2);
|
|
33
|
+
for (const row of p1(generate(Math.random, 1000000))) {
|
|
34
|
+
console.info(`${row.index}: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it("interesting example", () => {
|
|
38
|
+
const c1 = count();
|
|
39
|
+
const c2 = count();
|
|
40
|
+
const c3 = count();
|
|
41
|
+
const m1 = max(row => row.value);
|
|
42
|
+
const p1 = pipe(sensor(c1), // Keep running count of input
|
|
43
|
+
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
44
|
+
sensor(c2), // Keep running count of filtered rows
|
|
45
|
+
map((n, idx) => // Convert to JSON Object
|
|
46
|
+
({ index: idx, value: n })), filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
47
|
+
sensor(c3), // Keep running count of final rows
|
|
48
|
+
sensor(m1));
|
|
49
|
+
for (const row of p1(generate(Math.random, 1000000))) {
|
|
50
|
+
if (row.index % 100000 === 0) {
|
|
51
|
+
console.info(`${row.index}: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
/*
|
|
57
|
+
const process3 = pipe(
|
|
58
|
+
filter(n => n <= 0.5),
|
|
59
|
+
map((n, idx) => ({ index: idx, value: n })),
|
|
60
|
+
filter(row => row.index % 2 === 0),
|
|
61
|
+
sort((l, r) => l.value - r.value),
|
|
62
|
+
first(3)
|
|
63
|
+
);
|
|
64
|
+
console.log(...process3([]));
|
|
65
|
+
|
|
66
|
+
// Iterable output
|
|
67
|
+
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
68
|
+
filter(n => n <= 5),
|
|
69
|
+
map((n, idx) => ({ index: idx, value: n })),
|
|
70
|
+
filter(row => row.index % 2 === 0),
|
|
71
|
+
sort((l, r) => l.value - r.value),
|
|
72
|
+
first(3)
|
|
73
|
+
); // => { index: 0, value: 0 }, { index: 2, value: 2 }, { index: 4, value: 4 }
|
|
74
|
+
|
|
75
|
+
const process = pipe(
|
|
76
|
+
filter(n => n <= 5),
|
|
77
|
+
map((n, idx) => ({ index: idx, value: n })),
|
|
78
|
+
filter(row => row.index % 2 === 0),
|
|
79
|
+
sort((l, r) => l.value - r.value),
|
|
80
|
+
first(3)
|
|
81
|
+
);
|
|
82
|
+
console.log([...process([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]); // => { index: 0, value: 0 }, { index: 2, value: 2 }, { index: 4, value: 4 }
|
|
83
|
+
|
|
84
|
+
// Scalar output
|
|
85
|
+
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
86
|
+
process,
|
|
87
|
+
scalar(max(row => row.value))
|
|
88
|
+
); // => 4
|
|
89
|
+
|
|
90
|
+
const process_2 = pipe(
|
|
91
|
+
process,
|
|
92
|
+
scalar(min(row => row.value))
|
|
93
|
+
);
|
|
94
|
+
console.log(process_2([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); // => 0
|
|
95
|
+
*/
|
|
96
96
|
//# sourceMappingURL=readme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readme.js","sourceRoot":"","sources":["../../src/__tests__/readme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElF,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IAEpB,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QAErB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEjC,MAAM,EAAE,GAAG,IAAI,CACX,MAAM,CAA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AAG,CAAC,EAAe,8BAA8B;QAClE,MAAM,CAAC,EAAE,CAAC,EAA0B,uCAAuC;QAC3E,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAqB,2BAA2B;SAC3D,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAC/B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,6BAA6B;QACjE,MAAM,CAAC,EAAE,CAAC,EAA0B,oCAAoC;QACxE,MAAM,CAAC,EAAE,CAAC,CACb,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE;YAClD,IAAI,GAAG,CAAC,KAAK,GAAG,MAAM,KAAK,CAAC,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;aACxF;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCE"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { reduce, scalar } from "../index";
|
|
3
|
-
const data = [1, 2, 3, 4, 5];
|
|
4
|
-
const reduceFunc = (prev, row) => prev + row;
|
|
5
|
-
const expectedA = data.reduce(reduceFunc);
|
|
6
|
-
const expectedB = data.reduce(reduceFunc, 10);
|
|
7
|
-
describe("reduce", () => {
|
|
8
|
-
it("scalarActivity", () => {
|
|
9
|
-
const calcReduce = scalar(reduce(reduceFunc));
|
|
10
|
-
const calcReduce2 = scalar(reduce(reduceFunc, 10));
|
|
11
|
-
expect(calcReduce(data)).to.equal(expectedA);
|
|
12
|
-
expect(calcReduce2(data)).to.equal(expectedB);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { reduce, scalar } from "../index";
|
|
3
|
+
const data = [1, 2, 3, 4, 5];
|
|
4
|
+
const reduceFunc = (prev, row) => prev + row;
|
|
5
|
+
const expectedA = data.reduce(reduceFunc);
|
|
6
|
+
const expectedB = data.reduce(reduceFunc, 10);
|
|
7
|
+
describe("reduce", () => {
|
|
8
|
+
it("scalarActivity", () => {
|
|
9
|
+
const calcReduce = scalar(reduce(reduceFunc));
|
|
10
|
+
const calcReduce2 = scalar(reduce(reduceFunc, 10));
|
|
11
|
+
expect(calcReduce(data)).to.equal(expectedA);
|
|
12
|
+
expect(calcReduce2(data)).to.equal(expectedB);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
15
|
//# sourceMappingURL=reduce.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { skip } from "../index";
|
|
3
|
-
describe("skip", () => {
|
|
4
|
-
it("generator", () => {
|
|
5
|
-
expect([...skip(2)([])]).to.deep.equal([]);
|
|
6
|
-
expect([...skip(2)(["a", "b", "c"])]).to.deep.equal(["c"]);
|
|
7
|
-
});
|
|
8
|
-
it("scalarActivity", () => {
|
|
9
|
-
expect([...skip([], 22)]).to.deep.equal([]);
|
|
10
|
-
expect([...skip(["a", "b", "c"], 2)]).to.deep.equal(["c"]);
|
|
11
|
-
expect([...skip(["a", "b", "c"], 22)]).to.deep.equal([]);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { skip } from "../index";
|
|
3
|
+
describe("skip", () => {
|
|
4
|
+
it("generator", () => {
|
|
5
|
+
expect([...skip(2)([])]).to.deep.equal([]);
|
|
6
|
+
expect([...skip(2)(["a", "b", "c"])]).to.deep.equal(["c"]);
|
|
7
|
+
});
|
|
8
|
+
it("scalarActivity", () => {
|
|
9
|
+
expect([...skip([], 22)]).to.deep.equal([]);
|
|
10
|
+
expect([...skip(["a", "b", "c"], 2)]).to.deep.equal(["c"]);
|
|
11
|
+
expect([...skip(["a", "b", "c"], 22)]).to.deep.equal([]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
14
|
//# sourceMappingURL=skip.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { sort } from "../index";
|
|
3
|
-
import { population } from "./data";
|
|
4
|
-
function sortFunc(l, r) {
|
|
5
|
-
const retVal = l.lname.localeCompare(r.lname);
|
|
6
|
-
if (retVal === 0)
|
|
7
|
-
return l.fname.localeCompare(r.fname);
|
|
8
|
-
return retVal;
|
|
9
|
-
}
|
|
10
|
-
const expected = [...population].sort(sortFunc);
|
|
11
|
-
describe("sort", () => {
|
|
12
|
-
it("generator", () => {
|
|
13
|
-
expect([...sort(sortFunc)(population)]).to.deep.equal(expected);
|
|
14
|
-
});
|
|
15
|
-
it("scalarActivity", () => {
|
|
16
|
-
expect([...sort(population, sortFunc)]).to.deep.equal(expected);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { sort } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
function sortFunc(l, r) {
|
|
5
|
+
const retVal = l.lname.localeCompare(r.lname);
|
|
6
|
+
if (retVal === 0)
|
|
7
|
+
return l.fname.localeCompare(r.fname);
|
|
8
|
+
return retVal;
|
|
9
|
+
}
|
|
10
|
+
const expected = [...population].sort(sortFunc);
|
|
11
|
+
describe("sort", () => {
|
|
12
|
+
it("generator", () => {
|
|
13
|
+
expect([...sort(sortFunc)(population)]).to.deep.equal(expected);
|
|
14
|
+
});
|
|
15
|
+
it("scalarActivity", () => {
|
|
16
|
+
expect([...sort(population, sortFunc)]).to.deep.equal(expected);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
19
|
//# sourceMappingURL=sort.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { variance, scalar } from "../index";
|
|
3
|
-
describe("variance", () => {
|
|
4
|
-
it("scalarActivity", () => {
|
|
5
|
-
const calcVariance = scalar(variance());
|
|
6
|
-
expect(calcVariance([5, 1, 2, 3, 4])).to.equal(2.5);
|
|
7
|
-
});
|
|
8
|
-
it("empty array", () => {
|
|
9
|
-
const varianceActivity = scalar(variance());
|
|
10
|
-
expect(varianceActivity([])).to.be.undefined;
|
|
11
|
-
});
|
|
12
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { variance, scalar } from "../index";
|
|
3
|
+
describe("variance", () => {
|
|
4
|
+
it("scalarActivity", () => {
|
|
5
|
+
const calcVariance = scalar(variance());
|
|
6
|
+
expect(calcVariance([5, 1, 2, 3, 4])).to.equal(2.5);
|
|
7
|
+
});
|
|
8
|
+
it("empty array", () => {
|
|
9
|
+
const varianceActivity = scalar(variance());
|
|
10
|
+
expect(varianceActivity([])).to.be.undefined;
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
13
|
//# sourceMappingURL=variance.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function isSource(source) {
|
|
2
|
-
return typeof source[Symbol.iterator] === "function" || Array.isArray(source);
|
|
3
|
-
}
|
|
1
|
+
export function isSource(source) {
|
|
2
|
+
return typeof source[Symbol.iterator] === "function" || Array.isArray(source);
|
|
3
|
+
}
|
|
4
4
|
//# sourceMappingURL=activity.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function concatGen(concatSource) {
|
|
2
|
-
return function* (source) {
|
|
3
|
-
yield* source;
|
|
4
|
-
yield* concatSource;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export function concat(s_or_n, concatSource) {
|
|
8
|
-
return concatSource !== undefined ? concatGen(concatSource)(s_or_n) : concatGen(s_or_n);
|
|
9
|
-
}
|
|
1
|
+
function concatGen(concatSource) {
|
|
2
|
+
return function* (source) {
|
|
3
|
+
yield* source;
|
|
4
|
+
yield* concatSource;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function concat(s_or_n, concatSource) {
|
|
8
|
+
return concatSource !== undefined ? concatGen(concatSource)(s_or_n) : concatGen(s_or_n);
|
|
9
|
+
}
|
|
10
10
|
//# sourceMappingURL=concat.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { isSource } from "./activity";
|
|
2
|
-
function eachGen(callbackFn) {
|
|
3
|
-
return function* (source) {
|
|
4
|
-
let i = -1;
|
|
5
|
-
for (const item of source) {
|
|
6
|
-
callbackFn(item, ++i);
|
|
7
|
-
yield item;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function each(s_or_cb, callbackFn) {
|
|
12
|
-
return isSource(s_or_cb) ? eachGen(callbackFn)(s_or_cb) : eachGen(s_or_cb);
|
|
13
|
-
}
|
|
1
|
+
import { isSource } from "./activity";
|
|
2
|
+
function eachGen(callbackFn) {
|
|
3
|
+
return function* (source) {
|
|
4
|
+
let i = -1;
|
|
5
|
+
for (const item of source) {
|
|
6
|
+
callbackFn(item, ++i);
|
|
7
|
+
yield item;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function each(s_or_cb, callbackFn) {
|
|
12
|
+
return isSource(s_or_cb) ? eachGen(callbackFn)(s_or_cb) : eachGen(s_or_cb);
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=each.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// Array.entries
|
|
2
|
-
function entriesGen() {
|
|
3
|
-
return function* (source) {
|
|
4
|
-
let i = -1;
|
|
5
|
-
for (const item of source) {
|
|
6
|
-
yield [++i, item];
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function entries(source) {
|
|
11
|
-
return source ? entriesGen()(source) : entriesGen();
|
|
12
|
-
}
|
|
1
|
+
// Array.entries
|
|
2
|
+
function entriesGen() {
|
|
3
|
+
return function* (source) {
|
|
4
|
+
let i = -1;
|
|
5
|
+
for (const item of source) {
|
|
6
|
+
yield [++i, item];
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function entries(source) {
|
|
11
|
+
return source ? entriesGen()(source) : entriesGen();
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=entries.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { isSource } from "./activity";
|
|
2
|
-
function filterGen(callbackFn) {
|
|
3
|
-
return function* (source) {
|
|
4
|
-
let i = -1;
|
|
5
|
-
for (const item of source) {
|
|
6
|
-
if (callbackFn(item, ++i)) {
|
|
7
|
-
yield item;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function filter(s_or_cb, callbackFn) {
|
|
13
|
-
return isSource(s_or_cb) ? filterGen(callbackFn)(s_or_cb) : filterGen(s_or_cb);
|
|
14
|
-
}
|
|
1
|
+
import { isSource } from "./activity";
|
|
2
|
+
function filterGen(callbackFn) {
|
|
3
|
+
return function* (source) {
|
|
4
|
+
let i = -1;
|
|
5
|
+
for (const item of source) {
|
|
6
|
+
if (callbackFn(item, ++i)) {
|
|
7
|
+
yield item;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function filter(s_or_cb, callbackFn) {
|
|
13
|
+
return isSource(s_or_cb) ? filterGen(callbackFn)(s_or_cb) : filterGen(s_or_cb);
|
|
14
|
+
}
|
|
15
15
|
//# sourceMappingURL=filter.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { isSource } from "./activity";
|
|
2
|
-
function firstGen(n) {
|
|
3
|
-
return function* (source) {
|
|
4
|
-
let i = 0;
|
|
5
|
-
for (const item of source) {
|
|
6
|
-
yield item;
|
|
7
|
-
if (++i >= n) {
|
|
8
|
-
break;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function first(s_or_n, n) {
|
|
14
|
-
if (!isSource(s_or_n))
|
|
15
|
-
return firstGen(s_or_n);
|
|
16
|
-
return firstGen(n)(s_or_n);
|
|
17
|
-
}
|
|
1
|
+
import { isSource } from "./activity";
|
|
2
|
+
function firstGen(n) {
|
|
3
|
+
return function* (source) {
|
|
4
|
+
let i = 0;
|
|
5
|
+
for (const item of source) {
|
|
6
|
+
yield item;
|
|
7
|
+
if (++i >= n) {
|
|
8
|
+
break;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function first(s_or_n, n) {
|
|
14
|
+
if (!isSource(s_or_n))
|
|
15
|
+
return firstGen(s_or_n);
|
|
16
|
+
return firstGen(n)(s_or_n);
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=first.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { isSource } from "./activity";
|
|
2
|
-
function groupGen(groupFn) {
|
|
3
|
-
return function* (source) {
|
|
4
|
-
let i = -1;
|
|
5
|
-
const group = {};
|
|
6
|
-
for (const row of source) {
|
|
7
|
-
const key = groupFn(row, ++i);
|
|
8
|
-
if (!group[key]) {
|
|
9
|
-
group[key] = [];
|
|
10
|
-
}
|
|
11
|
-
group[key].push(row);
|
|
12
|
-
}
|
|
13
|
-
for (const key in group) {
|
|
14
|
-
yield { key, value: group[key] };
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function group(s_or_gbf, groupByFn) {
|
|
19
|
-
return isSource(s_or_gbf) ? groupGen(groupByFn)(s_or_gbf) : groupGen(s_or_gbf);
|
|
20
|
-
}
|
|
1
|
+
import { isSource } from "./activity";
|
|
2
|
+
function groupGen(groupFn) {
|
|
3
|
+
return function* (source) {
|
|
4
|
+
let i = -1;
|
|
5
|
+
const group = {};
|
|
6
|
+
for (const row of source) {
|
|
7
|
+
const key = groupFn(row, ++i);
|
|
8
|
+
if (!group[key]) {
|
|
9
|
+
group[key] = [];
|
|
10
|
+
}
|
|
11
|
+
group[key].push(row);
|
|
12
|
+
}
|
|
13
|
+
for (const key in group) {
|
|
14
|
+
yield { key, value: group[key] };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function group(s_or_gbf, groupByFn) {
|
|
19
|
+
return isSource(s_or_gbf) ? groupGen(groupByFn)(s_or_gbf) : groupGen(s_or_gbf);
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=group.js.map
|