@hpcc-js/dataflow 9.1.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.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib-es6/__package__.js +2 -2
- 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__/index.ts +27 -27
- package/src/__tests__/join.ts +20 -20
- 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__/normalize.ts +14 -14
- 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/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 +2 -2
- package/types/observers/observer.d.ts.map +1 -1
- package/types-3.4/__package__.d.ts +2 -2
package/src/__tests__/group.ts
CHANGED
|
@@ -1,19 +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
|
-
});
|
|
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
|
+
});
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { histogram } from "../index";
|
|
3
|
-
import { people, Person, population } from "./data";
|
|
4
|
-
|
|
5
|
-
describe("histogram", () => {
|
|
6
|
-
it("generator", () => {
|
|
7
|
-
const h = [...histogram<Person>(row => row.age, { buckets: 10 })(population)];
|
|
8
|
-
expect(h).to.have.length;
|
|
9
|
-
expect(h.length).to.equal(10);
|
|
10
|
-
expect(h[0].from).to.exist;
|
|
11
|
-
expect(h[0].to).to.exist;
|
|
12
|
-
expect(h[0].value).to.have.length;
|
|
13
|
-
|
|
14
|
-
const h2 = [...histogram<Person>(row => row.age, { min: 15, range: 5 })(population)];
|
|
15
|
-
expect(h2).to.have.length;
|
|
16
|
-
expect(h2.length).to.equal(11);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("generator 2", () => {
|
|
20
|
-
const h = [...histogram<Person>(row => row.age, { buckets: 10 })(people())];
|
|
21
|
-
expect(h).to.have.length;
|
|
22
|
-
expect(h.length).to.equal(10);
|
|
23
|
-
expect(h[0].from).to.exist;
|
|
24
|
-
expect(h[0].to).to.exist;
|
|
25
|
-
expect(h[0].value).to.have.length;
|
|
26
|
-
|
|
27
|
-
const h2 = [...histogram<Person>(row => row.age, { min: 15, range: 5 })(people())];
|
|
28
|
-
expect(h2).to.have.length;
|
|
29
|
-
expect(h2.length).to.equal(11);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("scalarActivity", () => {
|
|
33
|
-
const h = [...histogram(population, row => row.age, { buckets: 10 })];
|
|
34
|
-
expect(h).to.have.length;
|
|
35
|
-
expect(h[0].from).to.exist;
|
|
36
|
-
expect(h[0].to).to.exist;
|
|
37
|
-
expect(h[0].value).to.have.length;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("readme", () => {
|
|
41
|
-
const data = [1, 12, 13, 13, 3, 14, 19, 6];
|
|
42
|
-
const h = [...histogram(data, n => n, { buckets: 3 })];
|
|
43
|
-
expect(h).to.have.length;
|
|
44
|
-
const h2 = [...histogram(data, n => n, { min: 0, range: 5 })];
|
|
45
|
-
expect(h2).to.have.length;
|
|
46
|
-
});
|
|
47
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { histogram } from "../index";
|
|
3
|
+
import { people, Person, population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("histogram", () => {
|
|
6
|
+
it("generator", () => {
|
|
7
|
+
const h = [...histogram<Person>(row => row.age, { buckets: 10 })(population)];
|
|
8
|
+
expect(h).to.have.length;
|
|
9
|
+
expect(h.length).to.equal(10);
|
|
10
|
+
expect(h[0].from).to.exist;
|
|
11
|
+
expect(h[0].to).to.exist;
|
|
12
|
+
expect(h[0].value).to.have.length;
|
|
13
|
+
|
|
14
|
+
const h2 = [...histogram<Person>(row => row.age, { min: 15, range: 5 })(population)];
|
|
15
|
+
expect(h2).to.have.length;
|
|
16
|
+
expect(h2.length).to.equal(11);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("generator 2", () => {
|
|
20
|
+
const h = [...histogram<Person>(row => row.age, { buckets: 10 })(people())];
|
|
21
|
+
expect(h).to.have.length;
|
|
22
|
+
expect(h.length).to.equal(10);
|
|
23
|
+
expect(h[0].from).to.exist;
|
|
24
|
+
expect(h[0].to).to.exist;
|
|
25
|
+
expect(h[0].value).to.have.length;
|
|
26
|
+
|
|
27
|
+
const h2 = [...histogram<Person>(row => row.age, { min: 15, range: 5 })(people())];
|
|
28
|
+
expect(h2).to.have.length;
|
|
29
|
+
expect(h2.length).to.equal(11);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("scalarActivity", () => {
|
|
33
|
+
const h = [...histogram(population, row => row.age, { buckets: 10 })];
|
|
34
|
+
expect(h).to.have.length;
|
|
35
|
+
expect(h[0].from).to.exist;
|
|
36
|
+
expect(h[0].to).to.exist;
|
|
37
|
+
expect(h[0].value).to.have.length;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("readme", () => {
|
|
41
|
+
const data = [1, 12, 13, 13, 3, 14, 19, 6];
|
|
42
|
+
const h = [...histogram(data, n => n, { buckets: 3 })];
|
|
43
|
+
expect(h).to.have.length;
|
|
44
|
+
const h2 = [...histogram(data, n => n, { min: 0, range: 5 })];
|
|
45
|
+
expect(h2).to.have.length;
|
|
46
|
+
});
|
|
47
|
+
});
|
package/src/__tests__/index.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export * from "./chain";
|
|
2
|
-
export * from "./concat";
|
|
3
|
-
export * from "./count";
|
|
4
|
-
export * from "./data";
|
|
5
|
-
export * from "./deviation";
|
|
6
|
-
export * from "./distribution";
|
|
7
|
-
export * from "./each";
|
|
8
|
-
export * from "./entries";
|
|
9
|
-
export * from "./extent";
|
|
10
|
-
export * from "./filter";
|
|
11
|
-
export * from "./first";
|
|
12
|
-
export * from "./generate";
|
|
13
|
-
export * from "./group";
|
|
14
|
-
export * from "./histogram";
|
|
15
|
-
export * from "./join";
|
|
16
|
-
export * from "./map";
|
|
17
|
-
export * from "./max";
|
|
18
|
-
export * from "./mean";
|
|
19
|
-
export * from "./median";
|
|
20
|
-
export * from "./min";
|
|
21
|
-
export * from "./normalize";
|
|
22
|
-
export * from "./quartile";
|
|
23
|
-
export * from "./readme";
|
|
24
|
-
export * from "./reduce";
|
|
25
|
-
export * from "./skip";
|
|
26
|
-
export * from "./sort";
|
|
27
|
-
export * from "./variance";
|
|
1
|
+
export * from "./chain";
|
|
2
|
+
export * from "./concat";
|
|
3
|
+
export * from "./count";
|
|
4
|
+
export * from "./data";
|
|
5
|
+
export * from "./deviation";
|
|
6
|
+
export * from "./distribution";
|
|
7
|
+
export * from "./each";
|
|
8
|
+
export * from "./entries";
|
|
9
|
+
export * from "./extent";
|
|
10
|
+
export * from "./filter";
|
|
11
|
+
export * from "./first";
|
|
12
|
+
export * from "./generate";
|
|
13
|
+
export * from "./group";
|
|
14
|
+
export * from "./histogram";
|
|
15
|
+
export * from "./join";
|
|
16
|
+
export * from "./map";
|
|
17
|
+
export * from "./max";
|
|
18
|
+
export * from "./mean";
|
|
19
|
+
export * from "./median";
|
|
20
|
+
export * from "./min";
|
|
21
|
+
export * from "./normalize";
|
|
22
|
+
export * from "./quartile";
|
|
23
|
+
export * from "./readme";
|
|
24
|
+
export * from "./reduce";
|
|
25
|
+
export * from "./skip";
|
|
26
|
+
export * from "./sort";
|
|
27
|
+
export * from "./variance";
|
package/src/__tests__/join.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { each, join, map, normalize } from "../index";
|
|
3
|
-
import { Person, population } from "./data";
|
|
4
|
-
|
|
5
|
-
interface PersonEx extends Person {
|
|
6
|
-
normalizedAge: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
describe("join", () => {
|
|
10
|
-
it("normalize", () => {
|
|
11
|
-
const extractAge = map<Person, number>(row => row.age);
|
|
12
|
-
const normalizeFn = normalize();
|
|
13
|
-
const joinNormalizeAges = join(normalizeFn(extractAge(population)), (row: Person, age: number): PersonEx => ({ ...row, normalizedAge: age }));
|
|
14
|
-
const doTest = each(row => {
|
|
15
|
-
expect(row.normalizedAge).to.be.greaterThanOrEqual(0);
|
|
16
|
-
expect(row.normalizedAge).to.be.lessThanOrEqual(1);
|
|
17
|
-
});
|
|
18
|
-
[...doTest(joinNormalizeAges(population))];
|
|
19
|
-
});
|
|
20
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { each, join, map, normalize } from "../index";
|
|
3
|
+
import { Person, population } from "./data";
|
|
4
|
+
|
|
5
|
+
interface PersonEx extends Person {
|
|
6
|
+
normalizedAge: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe("join", () => {
|
|
10
|
+
it("normalize", () => {
|
|
11
|
+
const extractAge = map<Person, number>(row => row.age);
|
|
12
|
+
const normalizeFn = normalize();
|
|
13
|
+
const joinNormalizeAges = join(normalizeFn(extractAge(population)), (row: Person, age: number): PersonEx => ({ ...row, normalizedAge: age }));
|
|
14
|
+
const doTest = each(row => {
|
|
15
|
+
expect(row.normalizedAge).to.be.greaterThanOrEqual(0);
|
|
16
|
+
expect(row.normalizedAge).to.be.lessThanOrEqual(1);
|
|
17
|
+
});
|
|
18
|
+
[...doTest(joinNormalizeAges(population))];
|
|
19
|
+
});
|
|
20
|
+
});
|
package/src/__tests__/map.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { map } from "../index";
|
|
3
|
-
import { population } from "./data";
|
|
4
|
-
|
|
5
|
-
const testMap = row => ({ ...row.address });
|
|
6
|
-
const expected = population.map(testMap);
|
|
7
|
-
|
|
8
|
-
describe("map", () => {
|
|
9
|
-
it("generator", () => {
|
|
10
|
-
expect([...map(testMap)(population)]).to.deep.equal(expected);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("scalarActivity", () => {
|
|
14
|
-
expect([...map(population, testMap)]).to.deep.equal(expected);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { map } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
const testMap = row => ({ ...row.address });
|
|
6
|
+
const expected = population.map(testMap);
|
|
7
|
+
|
|
8
|
+
describe("map", () => {
|
|
9
|
+
it("generator", () => {
|
|
10
|
+
expect([...map(testMap)(population)]).to.deep.equal(expected);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("scalarActivity", () => {
|
|
14
|
+
expect([...map(population, testMap)]).to.deep.equal(expected);
|
|
15
|
+
});
|
|
16
|
+
});
|
package/src/__tests__/max.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { pipe, filter, max, scalar, sensor } from "../index";
|
|
3
|
-
import { population } from "./data";
|
|
4
|
-
|
|
5
|
-
describe("max", () => {
|
|
6
|
-
it("NumberArray", () => {
|
|
7
|
-
const s1 = max();
|
|
8
|
-
const s2 = max();
|
|
9
|
-
const p1 = pipe(
|
|
10
|
-
sensor(s1),
|
|
11
|
-
filter(r => r < 3),
|
|
12
|
-
sensor(s2),
|
|
13
|
-
);
|
|
14
|
-
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
15
|
-
expect(data.length).to.equal(3);
|
|
16
|
-
expect(s1.peek()).to.equal(5);
|
|
17
|
-
expect(s2.peek()).to.equal(2);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("Population", () => {
|
|
21
|
-
const s1 = max(r => r.age);
|
|
22
|
-
const s2 = max(r => r.age);
|
|
23
|
-
const p1 = pipe(
|
|
24
|
-
sensor(s1),
|
|
25
|
-
filter(r => r.age < 30),
|
|
26
|
-
sensor(s2),
|
|
27
|
-
);
|
|
28
|
-
const data = [...p1(population)];
|
|
29
|
-
expect(data.length).to.equal(286);
|
|
30
|
-
expect(s1.peek()).to.equal(66);
|
|
31
|
-
expect(s2.peek()).to.equal(29);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("scalarActivity", () => {
|
|
35
|
-
const s1 = scalar(max());
|
|
36
|
-
expect(s1([1, 2, 3, 4, 5, 0])).to.equal(5);
|
|
37
|
-
|
|
38
|
-
const s2 = scalar(max(r => r.age));
|
|
39
|
-
expect(s2(population)).to.equal(66);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { pipe, filter, max, scalar, sensor } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("max", () => {
|
|
6
|
+
it("NumberArray", () => {
|
|
7
|
+
const s1 = max();
|
|
8
|
+
const s2 = max();
|
|
9
|
+
const p1 = pipe(
|
|
10
|
+
sensor(s1),
|
|
11
|
+
filter(r => r < 3),
|
|
12
|
+
sensor(s2),
|
|
13
|
+
);
|
|
14
|
+
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
15
|
+
expect(data.length).to.equal(3);
|
|
16
|
+
expect(s1.peek()).to.equal(5);
|
|
17
|
+
expect(s2.peek()).to.equal(2);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("Population", () => {
|
|
21
|
+
const s1 = max(r => r.age);
|
|
22
|
+
const s2 = max(r => r.age);
|
|
23
|
+
const p1 = pipe(
|
|
24
|
+
sensor(s1),
|
|
25
|
+
filter(r => r.age < 30),
|
|
26
|
+
sensor(s2),
|
|
27
|
+
);
|
|
28
|
+
const data = [...p1(population)];
|
|
29
|
+
expect(data.length).to.equal(286);
|
|
30
|
+
expect(s1.peek()).to.equal(66);
|
|
31
|
+
expect(s2.peek()).to.equal(29);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("scalarActivity", () => {
|
|
35
|
+
const s1 = scalar(max());
|
|
36
|
+
expect(s1([1, 2, 3, 4, 5, 0])).to.equal(5);
|
|
37
|
+
|
|
38
|
+
const s2 = scalar(max(r => r.age));
|
|
39
|
+
expect(s2(population)).to.equal(66);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
package/src/__tests__/mean.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { mean, scalar } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("mean", () => {
|
|
5
|
-
it("scalarActivity", () => {
|
|
6
|
-
const a1 = scalar(mean());
|
|
7
|
-
expect(a1([5, -6, 1, 2, -2])).to.equal(0);
|
|
8
|
-
expect(a1([9])).to.deep.equal(9);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { mean, scalar } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("mean", () => {
|
|
5
|
+
it("scalarActivity", () => {
|
|
6
|
+
const a1 = scalar(mean());
|
|
7
|
+
expect(a1([5, -6, 1, 2, -2])).to.equal(0);
|
|
8
|
+
expect(a1([9])).to.deep.equal(9);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
package/src/__tests__/median.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { median, scalar } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("median", () => {
|
|
5
|
-
|
|
6
|
-
it("scalarActivity", () => {
|
|
7
|
-
const calcMedian = scalar(median());
|
|
8
|
-
expect(calcMedian([-6, -2, 1, 2, 5])).to.equal(1);
|
|
9
|
-
expect(calcMedian([5, -6, 1, 2, -2])).to.equal(1);
|
|
10
|
-
expect(calcMedian([-6, -2, 1, 2, 5, 6])).to.equal(1.5);
|
|
11
|
-
expect(calcMedian([5, -6, 1, 2, -2, 6])).to.equal(1.5);
|
|
12
|
-
expect(calcMedian([9])).to.deep.equal(9);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { median, scalar } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("median", () => {
|
|
5
|
+
|
|
6
|
+
it("scalarActivity", () => {
|
|
7
|
+
const calcMedian = scalar(median());
|
|
8
|
+
expect(calcMedian([-6, -2, 1, 2, 5])).to.equal(1);
|
|
9
|
+
expect(calcMedian([5, -6, 1, 2, -2])).to.equal(1);
|
|
10
|
+
expect(calcMedian([-6, -2, 1, 2, 5, 6])).to.equal(1.5);
|
|
11
|
+
expect(calcMedian([5, -6, 1, 2, -2, 6])).to.equal(1.5);
|
|
12
|
+
expect(calcMedian([9])).to.deep.equal(9);
|
|
13
|
+
});
|
|
14
|
+
});
|
package/src/__tests__/min.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { pipe, filter, min, scalar, sensor } from "../index";
|
|
3
|
-
import { population } from "./data";
|
|
4
|
-
|
|
5
|
-
describe("min", () => {
|
|
6
|
-
it("NumberArray", () => {
|
|
7
|
-
const s1 = min();
|
|
8
|
-
const s2 = min();
|
|
9
|
-
const p1 = pipe(
|
|
10
|
-
sensor(s1),
|
|
11
|
-
filter(r => r > 3),
|
|
12
|
-
sensor(s2),
|
|
13
|
-
);
|
|
14
|
-
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
15
|
-
expect(data.length).to.equal(2);
|
|
16
|
-
expect(s1.peek()).to.equal(0);
|
|
17
|
-
expect(s2.peek()).to.equal(4);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("Population", () => {
|
|
21
|
-
const s1 = min(r => r.age);
|
|
22
|
-
const s2 = min(r => r.age);
|
|
23
|
-
const p1 = pipe(
|
|
24
|
-
sensor(s1),
|
|
25
|
-
filter(r => r.age > 30),
|
|
26
|
-
sensor(s2),
|
|
27
|
-
);
|
|
28
|
-
const data = [...p1(population)];
|
|
29
|
-
expect(data.length).to.equal(699);
|
|
30
|
-
expect(s1.peek()).to.equal(16);
|
|
31
|
-
expect(s2.peek()).to.equal(31);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("scalarActivity", () => {
|
|
35
|
-
const a1 = scalar(min());
|
|
36
|
-
expect(a1([1, 2, 3, 4, 5, 0])).to.equal(0);
|
|
37
|
-
|
|
38
|
-
const a2 = scalar(min(r => r.age));
|
|
39
|
-
expect(a2(population)).to.equal(16);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { pipe, filter, min, scalar, sensor } from "../index";
|
|
3
|
+
import { population } from "./data";
|
|
4
|
+
|
|
5
|
+
describe("min", () => {
|
|
6
|
+
it("NumberArray", () => {
|
|
7
|
+
const s1 = min();
|
|
8
|
+
const s2 = min();
|
|
9
|
+
const p1 = pipe(
|
|
10
|
+
sensor(s1),
|
|
11
|
+
filter(r => r > 3),
|
|
12
|
+
sensor(s2),
|
|
13
|
+
);
|
|
14
|
+
const data = [...p1([1, 2, 3, 4, 5, 0])];
|
|
15
|
+
expect(data.length).to.equal(2);
|
|
16
|
+
expect(s1.peek()).to.equal(0);
|
|
17
|
+
expect(s2.peek()).to.equal(4);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("Population", () => {
|
|
21
|
+
const s1 = min(r => r.age);
|
|
22
|
+
const s2 = min(r => r.age);
|
|
23
|
+
const p1 = pipe(
|
|
24
|
+
sensor(s1),
|
|
25
|
+
filter(r => r.age > 30),
|
|
26
|
+
sensor(s2),
|
|
27
|
+
);
|
|
28
|
+
const data = [...p1(population)];
|
|
29
|
+
expect(data.length).to.equal(699);
|
|
30
|
+
expect(s1.peek()).to.equal(16);
|
|
31
|
+
expect(s2.peek()).to.equal(31);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("scalarActivity", () => {
|
|
35
|
+
const a1 = scalar(min());
|
|
36
|
+
expect(a1([1, 2, 3, 4, 5, 0])).to.equal(0);
|
|
37
|
+
|
|
38
|
+
const a2 = scalar(min(r => r.age));
|
|
39
|
+
expect(a2(population)).to.equal(16);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { normalize } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("normalize", () => {
|
|
5
|
-
|
|
6
|
-
it("numberArray", () => {
|
|
7
|
-
const normFunc = normalize();
|
|
8
|
-
expect([...normFunc([0, 5, 10])]).to.deep.equal([0, .5, 1]);
|
|
9
|
-
expect([...normFunc([0, 10, 20])]).to.deep.equal([0, .5, 1]);
|
|
10
|
-
expect([...normFunc([0, 1, 2, 3, 4])]).to.deep.equal([0, .25, .5, .75, 1]);
|
|
11
|
-
expect([...normFunc([0, 10, 20, 30, 40])]).to.deep.equal([0, .25, .5, .75, 1]);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { normalize } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("normalize", () => {
|
|
5
|
+
|
|
6
|
+
it("numberArray", () => {
|
|
7
|
+
const normFunc = normalize();
|
|
8
|
+
expect([...normFunc([0, 5, 10])]).to.deep.equal([0, .5, 1]);
|
|
9
|
+
expect([...normFunc([0, 10, 20])]).to.deep.equal([0, .5, 1]);
|
|
10
|
+
expect([...normFunc([0, 1, 2, 3, 4])]).to.deep.equal([0, .25, .5, .75, 1]);
|
|
11
|
+
expect([...normFunc([0, 10, 20, 30, 40])]).to.deep.equal([0, .25, .5, .75, 1]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { quartile, scalar } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("quartile", () => {
|
|
5
|
-
|
|
6
|
-
it("scalarActivity", () => {
|
|
7
|
-
const calcQuartile = scalar(quartile());
|
|
8
|
-
expect(calcQuartile([6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49])).to.deep.equal([6, 15, 40, 43, 49]);
|
|
9
|
-
expect(calcQuartile([7, 15, 36, 39, 40, 41])).to.deep.equal([7, 15, 37.5, 40, 41]);
|
|
10
|
-
expect(calcQuartile([1, 22, 133])).to.deep.equal([1, 1, 22, 133, 133]);
|
|
11
|
-
expect(calcQuartile([2, 144, 33])).to.deep.equal([2, 2, 33, 144, 144]);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { quartile, scalar } from "../index";
|
|
3
|
+
|
|
4
|
+
describe("quartile", () => {
|
|
5
|
+
|
|
6
|
+
it("scalarActivity", () => {
|
|
7
|
+
const calcQuartile = scalar(quartile());
|
|
8
|
+
expect(calcQuartile([6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49])).to.deep.equal([6, 15, 40, 43, 49]);
|
|
9
|
+
expect(calcQuartile([7, 15, 36, 39, 40, 41])).to.deep.equal([7, 15, 37.5, 40, 41]);
|
|
10
|
+
expect(calcQuartile([1, 22, 133])).to.deep.equal([1, 1, 22, 133, 133]);
|
|
11
|
+
expect(calcQuartile([2, 144, 33])).to.deep.equal([2, 2, 33, 144, 144]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|