@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.
Files changed (67) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +530 -530
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/lib-es6/__package__.js +2 -2
  7. package/package.json +3 -3
  8. package/src/__package__.ts +3 -3
  9. package/src/__tests__/chain.ts +85 -85
  10. package/src/__tests__/concat.ts +18 -18
  11. package/src/__tests__/count.ts +25 -25
  12. package/src/__tests__/data.ts +64 -64
  13. package/src/__tests__/deviation.ts +14 -14
  14. package/src/__tests__/distribution.ts +21 -21
  15. package/src/__tests__/each.ts +13 -13
  16. package/src/__tests__/entries.ts +14 -14
  17. package/src/__tests__/extent.ts +25 -25
  18. package/src/__tests__/filter.ts +16 -16
  19. package/src/__tests__/first.ts +15 -15
  20. package/src/__tests__/generate.ts +9 -9
  21. package/src/__tests__/group.ts +19 -19
  22. package/src/__tests__/histogram.ts +47 -47
  23. package/src/__tests__/index.ts +27 -27
  24. package/src/__tests__/join.ts +20 -20
  25. package/src/__tests__/map.ts +16 -16
  26. package/src/__tests__/max.ts +42 -42
  27. package/src/__tests__/mean.ts +11 -11
  28. package/src/__tests__/median.ts +14 -14
  29. package/src/__tests__/min.ts +42 -42
  30. package/src/__tests__/normalize.ts +14 -14
  31. package/src/__tests__/quartile.ts +14 -14
  32. package/src/__tests__/readme.ts +113 -113
  33. package/src/__tests__/reduce.ts +17 -17
  34. package/src/__tests__/skip.ts +15 -15
  35. package/src/__tests__/sort.ts +21 -21
  36. package/src/__tests__/variance.ts +14 -14
  37. package/src/activities/activity.ts +8 -8
  38. package/src/activities/concat.ts +14 -14
  39. package/src/activities/each.ts +19 -19
  40. package/src/activities/entries.ts +17 -17
  41. package/src/activities/filter.ts +20 -20
  42. package/src/activities/first.ts +20 -20
  43. package/src/activities/group.ts +27 -27
  44. package/src/activities/histogram.ts +78 -78
  45. package/src/activities/join.ts +19 -19
  46. package/src/activities/map.ts +18 -18
  47. package/src/activities/normalize.ts +21 -21
  48. package/src/activities/skip.ts +18 -18
  49. package/src/activities/sort.ts +16 -16
  50. package/src/index.ts +27 -27
  51. package/src/observers/count.ts +15 -15
  52. package/src/observers/deviation.ts +24 -24
  53. package/src/observers/distribution.ts +51 -51
  54. package/src/observers/extent.ts +24 -24
  55. package/src/observers/max.ts +24 -24
  56. package/src/observers/mean.ts +26 -26
  57. package/src/observers/median.ts +30 -30
  58. package/src/observers/min.ts +24 -24
  59. package/src/observers/observer.ts +52 -52
  60. package/src/observers/quartile.ts +43 -43
  61. package/src/observers/reduce.ts +22 -22
  62. package/src/observers/variance.ts +29 -29
  63. package/src/utils/generate.ts +6 -6
  64. package/src/utils/pipe.ts +74 -74
  65. package/types/__package__.d.ts +2 -2
  66. package/types/observers/observer.d.ts.map +1 -1
  67. package/types-3.4/__package__.d.ts +2 -2
@@ -1,85 +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
- });
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
+ });
@@ -1,18 +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
- });
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
+ });
@@ -1,25 +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
- });
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
+ });
@@ -1,64 +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
- });
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
+ });
@@ -1,14 +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
- });
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
+ });
@@ -1,21 +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
- });
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
+ });
@@ -1,13 +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
- });
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
+ });
@@ -1,14 +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
- });
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
+ });
@@ -1,25 +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
- });
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
+ });
@@ -1,16 +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
- });
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
+ });
@@ -1,15 +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
- });
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
+ });
@@ -1,9 +1,9 @@
1
- import { expect } from "chai";
2
- import { generate } from "../index";
3
-
4
- describe("generate", () => {
5
- it("basic", () => {
6
- expect([...generate(Math.random, 22)]).to.be.lengthOf(22);
7
- });
8
-
9
- });
1
+ import { expect } from "chai";
2
+ import { generate } from "../index";
3
+
4
+ describe("generate", () => {
5
+ it("basic", () => {
6
+ expect([...generate(Math.random, 22)]).to.be.lengthOf(22);
7
+ });
8
+
9
+ });