@hpcc-js/dataflow 8.0.1 → 8.1.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 +446 -446
- 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 +3 -3
- 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__/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 +6 -24
- 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/__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
package/src/__tests__/concat.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/count.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/data.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/each.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/entries.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/extent.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/filter.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/__tests__/first.ts
CHANGED
|
@@ -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
|
+
});
|
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__/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
|
+
});
|