@hpcc-js/dataflow 9.1.0 → 9.3.0
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/dist/index.js +396 -556
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +31 -36
- package/src/__package__.ts +2 -2
- package/src/activities/concat.ts +1 -1
- package/src/activities/each.ts +1 -1
- package/src/activities/entries.ts +1 -1
- package/src/activities/filter.ts +1 -1
- package/src/activities/first.ts +1 -1
- package/src/activities/group.ts +1 -1
- package/src/activities/histogram.ts +3 -3
- package/src/activities/join.ts +1 -1
- package/src/activities/map.ts +1 -1
- package/src/activities/normalize.ts +4 -4
- package/src/activities/skip.ts +1 -1
- package/src/activities/sort.ts +1 -1
- package/src/index.ts +27 -27
- package/src/observers/count.ts +1 -1
- package/src/observers/deviation.ts +2 -2
- package/src/observers/distribution.ts +5 -5
- package/src/observers/extent.ts +3 -3
- package/src/observers/max.ts +1 -1
- package/src/observers/mean.ts +1 -1
- package/src/observers/median.ts +1 -1
- package/src/observers/min.ts +1 -1
- package/src/observers/observer.ts +2 -2
- package/src/observers/quartile.ts +2 -2
- package/src/observers/reduce.ts +1 -1
- package/src/observers/variance.ts +1 -1
- package/src/utils/pipe.ts +3 -3
- package/types/activities/activity.d.ts +0 -1
- package/types/activities/concat.d.ts +1 -2
- package/types/activities/each.d.ts +1 -2
- package/types/activities/entries.d.ts +1 -2
- package/types/activities/filter.d.ts +1 -2
- package/types/activities/first.d.ts +1 -2
- package/types/activities/group.d.ts +1 -2
- package/types/activities/histogram.d.ts +1 -2
- package/types/activities/join.d.ts +1 -2
- package/types/activities/map.d.ts +1 -2
- package/types/activities/normalize.d.ts +1 -2
- package/types/activities/skip.d.ts +1 -2
- package/types/activities/sort.d.ts +1 -2
- package/types/index.d.ts +27 -28
- package/types/observers/count.d.ts +1 -2
- package/types/observers/deviation.d.ts +1 -2
- package/types/observers/distribution.d.ts +1 -2
- package/types/observers/extent.d.ts +1 -2
- package/types/observers/max.d.ts +1 -2
- package/types/observers/mean.d.ts +1 -2
- package/types/observers/median.d.ts +1 -2
- package/types/observers/min.d.ts +1 -2
- package/types/observers/observer.d.ts +2 -3
- package/types/observers/quartile.d.ts +1 -2
- package/types/observers/reduce.d.ts +1 -2
- package/types/observers/variance.d.ts +1 -2
- package/types/utils/generate.d.ts +0 -1
- package/types/utils/pipe.d.ts +1 -2
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/lib-es6/__package__.js +0 -4
- package/lib-es6/__package__.js.map +0 -1
- package/lib-es6/__tests__/chain.js +0 -49
- package/lib-es6/__tests__/chain.js.map +0 -1
- package/lib-es6/__tests__/concat.js +0 -17
- package/lib-es6/__tests__/concat.js.map +0 -1
- package/lib-es6/__tests__/count.js +0 -19
- package/lib-es6/__tests__/count.js.map +0 -1
- package/lib-es6/__tests__/data.js +0 -56
- package/lib-es6/__tests__/data.js.map +0 -1
- package/lib-es6/__tests__/deviation.js +0 -13
- package/lib-es6/__tests__/deviation.js.map +0 -1
- package/lib-es6/__tests__/distribution.js +0 -19
- package/lib-es6/__tests__/distribution.js.map +0 -1
- package/lib-es6/__tests__/each.js +0 -12
- package/lib-es6/__tests__/each.js.map +0 -1
- package/lib-es6/__tests__/entries.js +0 -13
- package/lib-es6/__tests__/entries.js.map +0 -1
- package/lib-es6/__tests__/extent.js +0 -19
- package/lib-es6/__tests__/extent.js.map +0 -1
- package/lib-es6/__tests__/filter.js +0 -14
- package/lib-es6/__tests__/filter.js.map +0 -1
- package/lib-es6/__tests__/first.js +0 -14
- package/lib-es6/__tests__/first.js.map +0 -1
- package/lib-es6/__tests__/generate.js +0 -8
- package/lib-es6/__tests__/generate.js.map +0 -1
- package/lib-es6/__tests__/group.js +0 -18
- package/lib-es6/__tests__/group.js.map +0 -1
- package/lib-es6/__tests__/histogram.js +0 -42
- package/lib-es6/__tests__/histogram.js.map +0 -1
- package/lib-es6/__tests__/index.js +0 -28
- package/lib-es6/__tests__/index.js.map +0 -1
- package/lib-es6/__tests__/join.js +0 -16
- package/lib-es6/__tests__/join.js.map +0 -1
- package/lib-es6/__tests__/map.js +0 -14
- package/lib-es6/__tests__/map.js.map +0 -1
- package/lib-es6/__tests__/max.js +0 -30
- package/lib-es6/__tests__/max.js.map +0 -1
- package/lib-es6/__tests__/mean.js +0 -10
- package/lib-es6/__tests__/mean.js.map +0 -1
- package/lib-es6/__tests__/median.js +0 -13
- package/lib-es6/__tests__/median.js.map +0 -1
- package/lib-es6/__tests__/min.js +0 -30
- package/lib-es6/__tests__/min.js.map +0 -1
- package/lib-es6/__tests__/normalize.js +0 -12
- package/lib-es6/__tests__/normalize.js.map +0 -1
- package/lib-es6/__tests__/quartile.js +0 -12
- package/lib-es6/__tests__/quartile.js.map +0 -1
- package/lib-es6/__tests__/readme.js +0 -96
- package/lib-es6/__tests__/readme.js.map +0 -1
- package/lib-es6/__tests__/reduce.js +0 -15
- package/lib-es6/__tests__/reduce.js.map +0 -1
- package/lib-es6/__tests__/skip.js +0 -14
- package/lib-es6/__tests__/skip.js.map +0 -1
- package/lib-es6/__tests__/sort.js +0 -19
- package/lib-es6/__tests__/sort.js.map +0 -1
- package/lib-es6/__tests__/variance.js +0 -13
- package/lib-es6/__tests__/variance.js.map +0 -1
- package/lib-es6/activities/activity.js +0 -4
- package/lib-es6/activities/activity.js.map +0 -1
- package/lib-es6/activities/concat.js +0 -10
- package/lib-es6/activities/concat.js.map +0 -1
- package/lib-es6/activities/each.js +0 -14
- package/lib-es6/activities/each.js.map +0 -1
- package/lib-es6/activities/entries.js +0 -13
- package/lib-es6/activities/entries.js.map +0 -1
- package/lib-es6/activities/filter.js +0 -15
- package/lib-es6/activities/filter.js.map +0 -1
- package/lib-es6/activities/first.js +0 -18
- package/lib-es6/activities/first.js.map +0 -1
- package/lib-es6/activities/group.js +0 -21
- package/lib-es6/activities/group.js.map +0 -1
- package/lib-es6/activities/histogram.js +0 -64
- package/lib-es6/activities/histogram.js.map +0 -1
- package/lib-es6/activities/join.js +0 -14
- package/lib-es6/activities/join.js.map +0 -1
- package/lib-es6/activities/map.js +0 -13
- package/lib-es6/activities/map.js.map +0 -1
- package/lib-es6/activities/normalize.js +0 -18
- package/lib-es6/activities/normalize.js.map +0 -1
- package/lib-es6/activities/skip.js +0 -15
- package/lib-es6/activities/skip.js.map +0 -1
- package/lib-es6/activities/sort.js +0 -10
- package/lib-es6/activities/sort.js.map +0 -1
- package/lib-es6/index.js +0 -28
- package/lib-es6/index.js.map +0 -1
- package/lib-es6/observers/count.js +0 -13
- package/lib-es6/observers/count.js.map +0 -1
- package/lib-es6/observers/deviation.js +0 -18
- package/lib-es6/observers/deviation.js.map +0 -1
- package/lib-es6/observers/distribution.js +0 -36
- package/lib-es6/observers/distribution.js.map +0 -1
- package/lib-es6/observers/extent.js +0 -18
- package/lib-es6/observers/extent.js.map +0 -1
- package/lib-es6/observers/max.js +0 -19
- package/lib-es6/observers/max.js.map +0 -1
- package/lib-es6/observers/mean.js +0 -21
- package/lib-es6/observers/mean.js.map +0 -1
- package/lib-es6/observers/median.js +0 -26
- package/lib-es6/observers/median.js.map +0 -1
- package/lib-es6/observers/min.js +0 -19
- package/lib-es6/observers/min.js.map +0 -1
- package/lib-es6/observers/observer.js +0 -35
- package/lib-es6/observers/observer.js.map +0 -1
- package/lib-es6/observers/quartile.js +0 -38
- package/lib-es6/observers/quartile.js.map +0 -1
- package/lib-es6/observers/reduce.js +0 -18
- package/lib-es6/observers/reduce.js.map +0 -1
- package/lib-es6/observers/variance.js +0 -23
- package/lib-es6/observers/variance.js.map +0 -1
- package/lib-es6/utils/generate.js +0 -7
- package/lib-es6/utils/generate.js.map +0 -1
- package/lib-es6/utils/pipe.js +0 -32
- package/lib-es6/utils/pipe.js.map +0 -1
- package/src/__tests__/chain.ts +0 -85
- package/src/__tests__/concat.ts +0 -18
- package/src/__tests__/count.ts +0 -25
- package/src/__tests__/data.ts +0 -64
- package/src/__tests__/deviation.ts +0 -14
- package/src/__tests__/distribution.ts +0 -21
- package/src/__tests__/each.ts +0 -13
- package/src/__tests__/entries.ts +0 -14
- package/src/__tests__/extent.ts +0 -25
- package/src/__tests__/filter.ts +0 -16
- package/src/__tests__/first.ts +0 -15
- package/src/__tests__/generate.ts +0 -9
- package/src/__tests__/group.ts +0 -19
- package/src/__tests__/histogram.ts +0 -47
- package/src/__tests__/index.ts +0 -27
- package/src/__tests__/join.ts +0 -20
- package/src/__tests__/map.ts +0 -16
- package/src/__tests__/max.ts +0 -42
- package/src/__tests__/mean.ts +0 -11
- package/src/__tests__/median.ts +0 -14
- package/src/__tests__/min.ts +0 -42
- package/src/__tests__/normalize.ts +0 -14
- package/src/__tests__/quartile.ts +0 -14
- package/src/__tests__/readme.ts +0 -113
- package/src/__tests__/reduce.ts +0 -17
- package/src/__tests__/skip.ts +0 -15
- package/src/__tests__/sort.ts +0 -21
- package/src/__tests__/variance.ts +0 -14
- package/types/__package__.d.ts +0 -4
- package/types/__package__.d.ts.map +0 -1
- package/types/__tests__/chain.d.ts +0 -2
- package/types/__tests__/chain.d.ts.map +0 -1
- package/types/__tests__/concat.d.ts +0 -2
- package/types/__tests__/concat.d.ts.map +0 -1
- package/types/__tests__/count.d.ts +0 -2
- package/types/__tests__/count.d.ts.map +0 -1
- package/types/__tests__/data.d.ts +0 -62
- package/types/__tests__/data.d.ts.map +0 -1
- package/types/__tests__/deviation.d.ts +0 -2
- package/types/__tests__/deviation.d.ts.map +0 -1
- package/types/__tests__/distribution.d.ts +0 -2
- package/types/__tests__/distribution.d.ts.map +0 -1
- package/types/__tests__/each.d.ts +0 -2
- package/types/__tests__/each.d.ts.map +0 -1
- package/types/__tests__/entries.d.ts +0 -2
- package/types/__tests__/entries.d.ts.map +0 -1
- package/types/__tests__/extent.d.ts +0 -2
- package/types/__tests__/extent.d.ts.map +0 -1
- package/types/__tests__/filter.d.ts +0 -2
- package/types/__tests__/filter.d.ts.map +0 -1
- package/types/__tests__/first.d.ts +0 -2
- package/types/__tests__/first.d.ts.map +0 -1
- package/types/__tests__/generate.d.ts +0 -2
- package/types/__tests__/generate.d.ts.map +0 -1
- package/types/__tests__/group.d.ts +0 -2
- package/types/__tests__/group.d.ts.map +0 -1
- package/types/__tests__/histogram.d.ts +0 -2
- package/types/__tests__/histogram.d.ts.map +0 -1
- package/types/__tests__/index.d.ts +0 -28
- package/types/__tests__/index.d.ts.map +0 -1
- package/types/__tests__/join.d.ts +0 -2
- package/types/__tests__/join.d.ts.map +0 -1
- package/types/__tests__/map.d.ts +0 -2
- package/types/__tests__/map.d.ts.map +0 -1
- package/types/__tests__/max.d.ts +0 -2
- package/types/__tests__/max.d.ts.map +0 -1
- package/types/__tests__/mean.d.ts +0 -2
- package/types/__tests__/mean.d.ts.map +0 -1
- package/types/__tests__/median.d.ts +0 -2
- package/types/__tests__/median.d.ts.map +0 -1
- package/types/__tests__/min.d.ts +0 -2
- package/types/__tests__/min.d.ts.map +0 -1
- package/types/__tests__/normalize.d.ts +0 -2
- package/types/__tests__/normalize.d.ts.map +0 -1
- package/types/__tests__/quartile.d.ts +0 -2
- package/types/__tests__/quartile.d.ts.map +0 -1
- package/types/__tests__/readme.d.ts +0 -2
- package/types/__tests__/readme.d.ts.map +0 -1
- package/types/__tests__/reduce.d.ts +0 -2
- package/types/__tests__/reduce.d.ts.map +0 -1
- package/types/__tests__/skip.d.ts +0 -2
- package/types/__tests__/skip.d.ts.map +0 -1
- package/types/__tests__/sort.d.ts +0 -2
- package/types/__tests__/sort.d.ts.map +0 -1
- package/types/__tests__/variance.d.ts +0 -2
- package/types/__tests__/variance.d.ts.map +0 -1
- package/types/activities/activity.d.ts.map +0 -1
- package/types/activities/concat.d.ts.map +0 -1
- package/types/activities/each.d.ts.map +0 -1
- package/types/activities/entries.d.ts.map +0 -1
- package/types/activities/filter.d.ts.map +0 -1
- package/types/activities/first.d.ts.map +0 -1
- package/types/activities/group.d.ts.map +0 -1
- package/types/activities/histogram.d.ts.map +0 -1
- package/types/activities/join.d.ts.map +0 -1
- package/types/activities/map.d.ts.map +0 -1
- package/types/activities/normalize.d.ts.map +0 -1
- package/types/activities/skip.d.ts.map +0 -1
- package/types/activities/sort.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/observers/count.d.ts.map +0 -1
- package/types/observers/deviation.d.ts.map +0 -1
- package/types/observers/distribution.d.ts.map +0 -1
- package/types/observers/extent.d.ts.map +0 -1
- package/types/observers/max.d.ts.map +0 -1
- package/types/observers/mean.d.ts.map +0 -1
- package/types/observers/median.d.ts.map +0 -1
- package/types/observers/min.d.ts.map +0 -1
- package/types/observers/observer.d.ts.map +0 -1
- package/types/observers/quartile.d.ts.map +0 -1
- package/types/observers/reduce.d.ts.map +0 -1
- package/types/observers/variance.d.ts.map +0 -1
- package/types/utils/generate.d.ts.map +0 -1
- package/types/utils/pipe.d.ts.map +0 -1
- package/types-3.4/__package__.d.ts +0 -4
- package/types-3.4/__tests__/chain.d.ts +0 -2
- package/types-3.4/__tests__/concat.d.ts +0 -2
- package/types-3.4/__tests__/count.d.ts +0 -2
- package/types-3.4/__tests__/data.d.ts +0 -62
- package/types-3.4/__tests__/deviation.d.ts +0 -2
- package/types-3.4/__tests__/distribution.d.ts +0 -2
- package/types-3.4/__tests__/each.d.ts +0 -2
- package/types-3.4/__tests__/entries.d.ts +0 -2
- package/types-3.4/__tests__/extent.d.ts +0 -2
- package/types-3.4/__tests__/filter.d.ts +0 -2
- package/types-3.4/__tests__/first.d.ts +0 -2
- package/types-3.4/__tests__/generate.d.ts +0 -2
- package/types-3.4/__tests__/group.d.ts +0 -2
- package/types-3.4/__tests__/histogram.d.ts +0 -2
- package/types-3.4/__tests__/index.d.ts +0 -28
- package/types-3.4/__tests__/join.d.ts +0 -2
- package/types-3.4/__tests__/map.d.ts +0 -2
- package/types-3.4/__tests__/max.d.ts +0 -2
- package/types-3.4/__tests__/mean.d.ts +0 -2
- package/types-3.4/__tests__/median.d.ts +0 -2
- package/types-3.4/__tests__/min.d.ts +0 -2
- package/types-3.4/__tests__/normalize.d.ts +0 -2
- package/types-3.4/__tests__/quartile.d.ts +0 -2
- package/types-3.4/__tests__/readme.d.ts +0 -2
- package/types-3.4/__tests__/reduce.d.ts +0 -2
- package/types-3.4/__tests__/skip.d.ts +0 -2
- package/types-3.4/__tests__/sort.d.ts +0 -2
- package/types-3.4/__tests__/variance.d.ts +0 -2
- package/types-3.4/activities/activity.d.ts +0 -6
- package/types-3.4/activities/concat.d.ts +0 -4
- package/types-3.4/activities/each.d.ts +0 -5
- package/types-3.4/activities/entries.d.ts +0 -10
- package/types-3.4/activities/filter.d.ts +0 -5
- package/types-3.4/activities/first.d.ts +0 -4
- package/types-3.4/activities/group.d.ts +0 -9
- package/types-3.4/activities/histogram.d.ts +0 -18
- package/types-3.4/activities/join.d.ts +0 -5
- package/types-3.4/activities/map.d.ts +0 -5
- package/types-3.4/activities/normalize.d.ts +0 -4
- package/types-3.4/activities/skip.d.ts +0 -4
- package/types-3.4/activities/sort.d.ts +0 -5
- package/types-3.4/index.d.ts +0 -28
- package/types-3.4/observers/count.d.ts +0 -3
- package/types-3.4/observers/deviation.d.ts +0 -5
- package/types-3.4/observers/distribution.d.ts +0 -13
- package/types-3.4/observers/extent.d.ts +0 -11
- package/types-3.4/observers/max.d.ts +0 -5
- package/types-3.4/observers/mean.d.ts +0 -5
- package/types-3.4/observers/median.d.ts +0 -5
- package/types-3.4/observers/min.d.ts +0 -5
- package/types-3.4/observers/observer.d.ts +0 -14
- package/types-3.4/observers/quartile.d.ts +0 -12
- package/types-3.4/observers/reduce.d.ts +0 -4
- package/types-3.4/observers/variance.d.ts +0 -5
- package/types-3.4/utils/generate.d.ts +0 -2
- package/types-3.4/utils/pipe.d.ts +0 -42
package/src/__tests__/data.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
});
|
package/src/__tests__/group.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
|
-
|
package/src/__tests__/readme.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
|
|
3
|
-
import { count, filter, first, generate, map, max, pipe, sensor } from "../index";
|
|
4
|
-
|
|
5
|
-
describe("readme", () => {
|
|
6
|
-
|
|
7
|
-
it("quick example", () => {
|
|
8
|
-
|
|
9
|
-
const c1 = count();
|
|
10
|
-
const c2 = count();
|
|
11
|
-
const c3 = count();
|
|
12
|
-
const m1 = max(row => row.value);
|
|
13
|
-
|
|
14
|
-
const p1 = pipe(
|
|
15
|
-
sensor(c1), // Keep running count of input
|
|
16
|
-
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
17
|
-
sensor(c2), // Keep running count of filtered rows
|
|
18
|
-
map((n, idx) => // Convert to JSON Object
|
|
19
|
-
({ index: idx, value: n })),
|
|
20
|
-
filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
21
|
-
sensor(c3), // Keep running count of final rows
|
|
22
|
-
sensor(m1), // Track largest value
|
|
23
|
-
first(3) // Take first 3 rows
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}`);
|
|
27
|
-
// [1] => Counts: undefined, undefined, undefined
|
|
28
|
-
const outIterable = p1(generate(Math.random, 1000));
|
|
29
|
-
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}`);
|
|
30
|
-
// [2] => Counts: undefined, undefined, undefined
|
|
31
|
-
console.info(JSON.stringify([...outIterable]));
|
|
32
|
-
// [3] => [{"index":0,"value":0.19075931906641008},{"index":2,"value":0.4873469062925415},{"index":4,"value":0.4412516774100035}]
|
|
33
|
-
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
34
|
-
// [4] => Counts: 6, 5, 3, 0.4873469062925415
|
|
35
|
-
|
|
36
|
-
const outArray = [...p1([0.7, 0.5, 0.4, 0.8, 0.3, 1])];
|
|
37
|
-
console.info(JSON.stringify(outArray));
|
|
38
|
-
// [5] => [{"index":0,"value":0.5},{"index":2,"value":0.3}]
|
|
39
|
-
console.info(`Counts: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
40
|
-
// [6] => Counts: 6, 3, 2, 0.5
|
|
41
|
-
|
|
42
|
-
expect(outArray.length).to.equal(2);
|
|
43
|
-
|
|
44
|
-
for (const row of p1(generate(Math.random, 1000000))) {
|
|
45
|
-
console.info(`${row.index}: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("interesting example", () => {
|
|
50
|
-
const c1 = count();
|
|
51
|
-
const c2 = count();
|
|
52
|
-
const c3 = count();
|
|
53
|
-
const m1 = max(row => row.value);
|
|
54
|
-
|
|
55
|
-
const p1 = pipe(
|
|
56
|
-
sensor(c1), // Keep running count of input
|
|
57
|
-
filter(n => n <= 0.5), // Filter out numbers > 0.5
|
|
58
|
-
sensor(c2), // Keep running count of filtered rows
|
|
59
|
-
map((n, idx) => // Convert to JSON Object
|
|
60
|
-
({ index: idx, value: n })),
|
|
61
|
-
filter(row => row.index % 2 === 0), // Filter even row indecies
|
|
62
|
-
sensor(c3), // Keep running count of final rows
|
|
63
|
-
sensor(m1), // Track largest value
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
for (const row of p1(generate(Math.random, 1000000))) {
|
|
67
|
-
if (row.index % 100000 === 0) {
|
|
68
|
-
console.info(`${row.index}: ${c1.peek()}, ${c2.peek()}, ${c3.peek()}, ${m1.peek()}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
const process3 = pipe(
|
|
76
|
-
filter(n => n <= 0.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(...process3([]));
|
|
83
|
-
|
|
84
|
-
// Iterable output
|
|
85
|
-
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
86
|
-
filter(n => n <= 5),
|
|
87
|
-
map((n, idx) => ({ index: idx, value: n })),
|
|
88
|
-
filter(row => row.index % 2 === 0),
|
|
89
|
-
sort((l, r) => l.value - r.value),
|
|
90
|
-
first(3)
|
|
91
|
-
); // => { index: 0, value: 0 }, { index: 2, value: 2 }, { index: 4, value: 4 }
|
|
92
|
-
|
|
93
|
-
const process = pipe(
|
|
94
|
-
filter(n => n <= 5),
|
|
95
|
-
map((n, idx) => ({ index: idx, value: n })),
|
|
96
|
-
filter(row => row.index % 2 === 0),
|
|
97
|
-
sort((l, r) => l.value - r.value),
|
|
98
|
-
first(3)
|
|
99
|
-
);
|
|
100
|
-
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 }
|
|
101
|
-
|
|
102
|
-
// Scalar output
|
|
103
|
-
pipe([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
104
|
-
process,
|
|
105
|
-
scalar(max(row => row.value))
|
|
106
|
-
); // => 4
|
|
107
|
-
|
|
108
|
-
const process_2 = pipe(
|
|
109
|
-
process,
|
|
110
|
-
scalar(min(row => row.value))
|
|
111
|
-
);
|
|
112
|
-
console.log(process_2([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); // => 0
|
|
113
|
-
*/
|
package/src/__tests__/reduce.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { reduce, scalar } from "../index";
|
|
3
|
-
|
|
4
|
-
const data = [1, 2, 3, 4, 5];
|
|
5
|
-
const reduceFunc = (prev, row) => prev + row;
|
|
6
|
-
const expectedA = data.reduce(reduceFunc);
|
|
7
|
-
const expectedB = data.reduce(reduceFunc, 10);
|
|
8
|
-
|
|
9
|
-
describe("reduce", () => {
|
|
10
|
-
|
|
11
|
-
it("scalarActivity", () => {
|
|
12
|
-
const calcReduce = scalar(reduce(reduceFunc));
|
|
13
|
-
const calcReduce2 = scalar(reduce(reduceFunc, 10));
|
|
14
|
-
expect(calcReduce(data)).to.equal(expectedA);
|
|
15
|
-
expect(calcReduce2(data)).to.equal(expectedB);
|
|
16
|
-
});
|
|
17
|
-
});
|
package/src/__tests__/skip.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { skip } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("skip", () => {
|
|
5
|
-
it("generator", () => {
|
|
6
|
-
expect([...skip(2)([])]).to.deep.equal([]);
|
|
7
|
-
expect([...skip(2)(["a", "b", "c"])]).to.deep.equal(["c"]);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("scalarActivity", () => {
|
|
11
|
-
expect([...skip([], 22)]).to.deep.equal([]);
|
|
12
|
-
expect([...skip(["a", "b", "c"], 2)]).to.deep.equal(["c"]);
|
|
13
|
-
expect([...skip(["a", "b", "c"], 22)]).to.deep.equal([]);
|
|
14
|
-
});
|
|
15
|
-
});
|
package/src/__tests__/sort.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { sort } from "../index";
|
|
3
|
-
import { Person, population } from "./data";
|
|
4
|
-
|
|
5
|
-
function sortFunc(l: Person, r: Person): number {
|
|
6
|
-
const retVal = l.lname.localeCompare(r.lname);
|
|
7
|
-
if (retVal === 0) return l.fname.localeCompare(r.fname);
|
|
8
|
-
return retVal;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const expected = [...population].sort(sortFunc);
|
|
12
|
-
|
|
13
|
-
describe("sort", () => {
|
|
14
|
-
it("generator", () => {
|
|
15
|
-
expect([...sort(sortFunc)(population)]).to.deep.equal(expected);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("scalarActivity", () => {
|
|
19
|
-
expect([...sort(population, sortFunc)]).to.deep.equal(expected);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { variance, scalar } from "../index";
|
|
3
|
-
|
|
4
|
-
describe("variance", () => {
|
|
5
|
-
it("scalarActivity", () => {
|
|
6
|
-
const calcVariance = scalar(variance());
|
|
7
|
-
expect(calcVariance([5, 1, 2, 3, 4])).to.equal(2.5);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("empty array", () => {
|
|
11
|
-
const varianceActivity = scalar(variance());
|
|
12
|
-
expect(varianceActivity([])).to.be.undefined;
|
|
13
|
-
});
|
|
14
|
-
});
|