triangle-types 1.0.84 → 1.0.86
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,5 +1,6 @@
|
|
|
1
1
|
import { StateID } from "../State.js";
|
|
2
2
|
import { PrismTarget } from "./PrismTarget.js";
|
|
3
|
+
import { VoterPartyTypeID } from "./Voter.js";
|
|
3
4
|
export declare class Prism {
|
|
4
5
|
readonly prism_id: string;
|
|
5
6
|
readonly state_id: StateID;
|
|
@@ -7,6 +8,7 @@ export declare class Prism {
|
|
|
7
8
|
readonly federal_congress_district_id?: string;
|
|
8
9
|
readonly state_legislature_house_district_id?: string;
|
|
9
10
|
readonly state_legislature_senate_district_id?: string;
|
|
11
|
+
readonly party_type_id: VoterPartyTypeID;
|
|
10
12
|
readonly [x: string]: any;
|
|
11
13
|
constructor(prism: any);
|
|
12
14
|
static is(prism: any): prism is Prism;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { is_state_id } from "../State.js";
|
|
2
2
|
import { PrismTarget } from "./PrismTarget.js";
|
|
3
|
+
import { is_voter_party_type_id } from "./Voter.js";
|
|
3
4
|
export class Prism {
|
|
4
5
|
prism_id;
|
|
5
6
|
state_id;
|
|
@@ -7,6 +8,7 @@ export class Prism {
|
|
|
7
8
|
federal_congress_district_id;
|
|
8
9
|
state_legislature_house_district_id;
|
|
9
10
|
state_legislature_senate_district_id;
|
|
11
|
+
party_type_id;
|
|
10
12
|
constructor(prism) {
|
|
11
13
|
if (!Prism.is(prism)) {
|
|
12
14
|
throw Error("Invalid input.");
|
|
@@ -17,6 +19,7 @@ export class Prism {
|
|
|
17
19
|
this.federal_congress_district_id = prism.federal_congress_district_id;
|
|
18
20
|
this.state_legislature_house_district_id = prism.state_legislature_house_district_id;
|
|
19
21
|
this.state_legislature_senate_district_id = prism.state_legislature_senate_district_id;
|
|
22
|
+
this.party_type_id = prism.party_type_id;
|
|
20
23
|
}
|
|
21
24
|
static is(prism) {
|
|
22
25
|
return (prism !== undefined &&
|
|
@@ -25,7 +28,8 @@ export class Prism {
|
|
|
25
28
|
typeof prism.name === "string" &&
|
|
26
29
|
(prism.federal_congress_district_id === undefined || typeof prism.federal_congress_district_id === "string") &&
|
|
27
30
|
(prism.state_legislature_house_district_id === undefined || typeof prism.state_legislature_house_district_id === "string") &&
|
|
28
|
-
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string")
|
|
31
|
+
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string") &&
|
|
32
|
+
is_voter_party_type_id(prism.party_type_id));
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
export class PrismAux extends Prism {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StateID } from "../State.js";
|
|
2
2
|
import { VoterTarget } from "./VoterTarget.js";
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout.js";
|
|
4
|
-
declare const voter_party_type_ids: readonly ["D", "R", "I"];
|
|
4
|
+
export declare const voter_party_type_ids: readonly ["D", "R", "I"];
|
|
5
5
|
export type VoterPartyTypeID = typeof voter_party_type_ids[number];
|
|
6
6
|
export declare function is_voter_party_type_id(voter_party_type_id: any): voter_party_type_id is VoterPartyTypeID;
|
|
7
7
|
export declare class Voter {
|
|
@@ -53,4 +53,3 @@ export declare class VoterAux extends Voter {
|
|
|
53
53
|
constructor(voter: any);
|
|
54
54
|
static is(voter: any): voter is Voter;
|
|
55
55
|
}
|
|
56
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is_state_id } from "../State.js";
|
|
2
2
|
import { VoterTarget } from "./VoterTarget.js";
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout.js";
|
|
4
|
-
const voter_party_type_ids = ["D", "R", "I"];
|
|
4
|
+
export const voter_party_type_ids = ["D", "R", "I"];
|
|
5
5
|
export function is_voter_party_type_id(voter_party_type_id) {
|
|
6
6
|
return voter_party_type_ids.includes(voter_party_type_id);
|
|
7
7
|
}
|
package/package.json
CHANGED
package/src/types/prism/Prism.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { is_state_id, StateID } from "../State"
|
|
2
2
|
import { PrismTarget } from "./PrismTarget"
|
|
3
|
+
import { is_voter_party_type_id, VoterPartyTypeID } from "./Voter"
|
|
3
4
|
|
|
4
5
|
export class Prism {
|
|
5
6
|
readonly prism_id : string
|
|
@@ -8,6 +9,7 @@ export class Prism {
|
|
|
8
9
|
readonly federal_congress_district_id? : string
|
|
9
10
|
readonly state_legislature_house_district_id? : string
|
|
10
11
|
readonly state_legislature_senate_district_id? : string
|
|
12
|
+
readonly party_type_id : VoterPartyTypeID
|
|
11
13
|
readonly [x : string] : any
|
|
12
14
|
|
|
13
15
|
constructor(prism : any) {
|
|
@@ -20,6 +22,7 @@ export class Prism {
|
|
|
20
22
|
this.federal_congress_district_id = prism.federal_congress_district_id
|
|
21
23
|
this.state_legislature_house_district_id = prism.state_legislature_house_district_id
|
|
22
24
|
this.state_legislature_senate_district_id = prism.state_legislature_senate_district_id
|
|
25
|
+
this.party_type_id = prism.party_type_id
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
static is(prism : any) : prism is Prism {
|
|
@@ -30,7 +33,8 @@ export class Prism {
|
|
|
30
33
|
typeof prism.name === "string" &&
|
|
31
34
|
(prism.federal_congress_district_id === undefined || typeof prism.federal_congress_district_id === "string") &&
|
|
32
35
|
(prism.state_legislature_house_district_id === undefined || typeof prism.state_legislature_house_district_id === "string") &&
|
|
33
|
-
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string")
|
|
36
|
+
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string") &&
|
|
37
|
+
is_voter_party_type_id(prism.party_type_id)
|
|
34
38
|
)
|
|
35
39
|
}
|
|
36
40
|
}
|
package/src/types/prism/Voter.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { is_state_id, StateID } from "../State"
|
|
|
2
2
|
import { VoterTarget } from "./VoterTarget"
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout"
|
|
4
4
|
|
|
5
|
-
const voter_party_type_ids = ["D", "R", "I"] as const
|
|
5
|
+
export const voter_party_type_ids = ["D", "R", "I"] as const
|
|
6
6
|
|
|
7
7
|
export type VoterPartyTypeID = typeof voter_party_type_ids[number]
|
|
8
8
|
|