elections-types 1.0.39 → 1.0.41
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.
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate.js";
|
|
2
|
+
import { Committee } from "./Committee.js";
|
|
1
3
|
import { StateID } from "./State.js";
|
|
2
4
|
declare const office_ids: readonly ["H", "S"];
|
|
3
5
|
export type OfficeID = typeof office_ids[number];
|
|
@@ -12,7 +14,14 @@ export declare class Election {
|
|
|
12
14
|
readonly district?: number;
|
|
13
15
|
readonly candidate_ids?: string[];
|
|
14
16
|
readonly committee_ids?: string[];
|
|
17
|
+
readonly [x: string]: any;
|
|
15
18
|
constructor(election: any);
|
|
16
19
|
static is(election: any): election is Election;
|
|
17
20
|
}
|
|
21
|
+
export declare class ElectionAux extends Election {
|
|
22
|
+
readonly candidates: Candidate[];
|
|
23
|
+
readonly committees: Committee[];
|
|
24
|
+
constructor(election: any);
|
|
25
|
+
static is(election: any): election is ElectionAux;
|
|
26
|
+
}
|
|
18
27
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate.js";
|
|
2
|
+
import { Committee } from "./Committee.js";
|
|
1
3
|
import { is_state_id } from "./State.js";
|
|
2
4
|
const office_ids = ["H", "S"];
|
|
3
5
|
export function is_office_id(office_id) {
|
|
@@ -48,3 +50,22 @@ export class Election {
|
|
|
48
50
|
(election.committee_ids === undefined || Array.isArray(election.committee_ids) && election.committee_ids.every((committee_id) => typeof committee_id === "string")));
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
export class ElectionAux extends Election {
|
|
54
|
+
candidates;
|
|
55
|
+
committees;
|
|
56
|
+
constructor(election) {
|
|
57
|
+
if (!ElectionAux.is(election)) {
|
|
58
|
+
throw Error("Invalid input.");
|
|
59
|
+
}
|
|
60
|
+
super(election);
|
|
61
|
+
this.candidates = election.candidates;
|
|
62
|
+
this.committees = election.committees;
|
|
63
|
+
}
|
|
64
|
+
static is(election) {
|
|
65
|
+
return (Election.is(election) &&
|
|
66
|
+
Array.isArray(election.candidates) &&
|
|
67
|
+
election.candidates.every(Candidate.is) &&
|
|
68
|
+
Array.isArray(election.committees) &&
|
|
69
|
+
election.committees.every(Committee.is));
|
|
70
|
+
}
|
|
71
|
+
}
|
package/package.json
CHANGED
package/src/types/Election.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate"
|
|
2
|
+
import { Committee } from "./Committee"
|
|
1
3
|
import { is_state_id, state_ids, StateID } from "./State"
|
|
2
4
|
|
|
3
5
|
const office_ids = ["H", "S"] as const
|
|
@@ -36,6 +38,7 @@ export class Election {
|
|
|
36
38
|
readonly district? : number
|
|
37
39
|
readonly candidate_ids? : string[]
|
|
38
40
|
readonly committee_ids? : string[]
|
|
41
|
+
readonly [x : string] : any
|
|
39
42
|
|
|
40
43
|
constructor(election : any) {
|
|
41
44
|
if (!Election.is(election)) {
|
|
@@ -62,4 +65,28 @@ export class Election {
|
|
|
62
65
|
(election.committee_ids === undefined || Array.isArray(election.committee_ids) && election.committee_ids.every((committee_id : any) => typeof committee_id === "string"))
|
|
63
66
|
)
|
|
64
67
|
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class ElectionAux extends Election {
|
|
71
|
+
readonly candidates : Candidate[]
|
|
72
|
+
readonly committees : Committee[]
|
|
73
|
+
|
|
74
|
+
constructor(election : any) {
|
|
75
|
+
if (!ElectionAux.is(election)) {
|
|
76
|
+
throw Error("Invalid input.")
|
|
77
|
+
}
|
|
78
|
+
super(election)
|
|
79
|
+
this.candidates = election.candidates
|
|
80
|
+
this.committees = election.committees
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static is(election : any) : election is ElectionAux {
|
|
84
|
+
return (
|
|
85
|
+
Election.is(election) &&
|
|
86
|
+
Array.isArray(election.candidates) &&
|
|
87
|
+
election.candidates.every(Candidate.is) &&
|
|
88
|
+
Array.isArray(election.committees) &&
|
|
89
|
+
election.committees.every(Committee.is)
|
|
90
|
+
)
|
|
91
|
+
}
|
|
65
92
|
}
|