triangle-types 1.0.83 → 1.0.85

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,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 {
@@ -30,6 +30,8 @@ export declare class Voter {
30
30
  readonly federal_congress_district_id: string;
31
31
  readonly state_legislature_house_district_id: string;
32
32
  readonly state_legislature_senate_district_id: string;
33
+ readonly party_description?: string;
34
+ readonly party_type_id: VoterPartyTypeID;
33
35
  readonly occupation_group?: string;
34
36
  readonly occupation_description?: string;
35
37
  readonly phone_home?: string;
@@ -38,8 +40,6 @@ export declare class Voter {
38
40
  readonly ethnic_group?: string;
39
41
  readonly ethnic_description?: string;
40
42
  readonly religion_description?: string;
41
- readonly party_description?: string;
42
- readonly party_type_id?: VoterPartyTypeID;
43
43
  readonly language?: string;
44
44
  readonly education_level?: string;
45
45
  readonly marital_status?: string;
@@ -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
  }
@@ -31,6 +31,8 @@ export class Voter {
31
31
  federal_congress_district_id;
32
32
  state_legislature_house_district_id;
33
33
  state_legislature_senate_district_id;
34
+ party_description;
35
+ party_type_id;
34
36
  occupation_group;
35
37
  occupation_description;
36
38
  phone_home;
@@ -39,8 +41,6 @@ export class Voter {
39
41
  ethnic_group;
40
42
  ethnic_description;
41
43
  religion_description;
42
- party_description;
43
- party_type_id;
44
44
  language;
45
45
  education_level;
46
46
  marital_status;
@@ -73,6 +73,8 @@ export class Voter {
73
73
  this.federal_congress_district_id = voter.federal_congress_district_id;
74
74
  this.state_legislature_house_district_id = voter.state_legislature_house_district_id;
75
75
  this.state_legislature_senate_district_id = voter.state_legislature_senate_district_id;
76
+ this.party_description = voter.party_description;
77
+ this.party_type_id = voter.party_type_id;
76
78
  this.occupation_group = voter.occupation_group;
77
79
  this.occupation_description = voter.occupation_description;
78
80
  this.phone_home = voter.phone_home;
@@ -81,8 +83,6 @@ export class Voter {
81
83
  this.ethnic_group = voter.ethnic_group;
82
84
  this.ethnic_description = voter.ethnic_description;
83
85
  this.religion_description = voter.religion_description;
84
- this.party_description = voter.party_description;
85
- this.party_type_id = voter.party_type_id;
86
86
  this.language = voter.language;
87
87
  this.education_level = voter.education_level;
88
88
  this.marital_status = voter.marital_status;
@@ -114,6 +114,8 @@ export class Voter {
114
114
  typeof voter.federal_congress_district_id === "string" &&
115
115
  typeof voter.state_legislature_house_district_id === "string" &&
116
116
  typeof voter.state_legislature_senate_district_id === "string" &&
117
+ (voter.party_description === undefined || typeof voter.party_description === "string") &&
118
+ is_voter_party_type_id(voter.party_type_id) &&
117
119
  (voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
118
120
  (voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
119
121
  (voter.phone_home === undefined || typeof voter.phone_home === "string") &&
@@ -122,8 +124,6 @@ export class Voter {
122
124
  (voter.ethnic_group === undefined || typeof voter.ethnic_group === "string") &&
123
125
  (voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
124
126
  (voter.religion_description === undefined || typeof voter.religion_description === "string") &&
125
- (voter.party_description === undefined || typeof voter.party_description === "string") &&
126
- (voter.party_type_id === undefined || is_voter_party_type_id(voter.party_type_id)) &&
127
127
  (voter.language === undefined || typeof voter.language === "string") &&
128
128
  (voter.education_level === undefined || typeof voter.education_level === "string") &&
129
129
  (voter.marital_status === undefined || typeof voter.marital_status === "string"));
@@ -1,4 +1,5 @@
1
1
  import { StateID } from "../State.js";
2
+ import { VoterPartyTypeID } from "./Voter.js";
2
3
  export declare class VoterTarget {
3
4
  readonly voter_target_id: string;
4
5
  readonly voter_id: string;
@@ -8,6 +9,7 @@ export declare class VoterTarget {
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
  constructor(voter_target: any);
12
14
  static is(voter_target: any): voter_target is VoterTarget;
13
15
  }
@@ -1,4 +1,5 @@
1
1
  import { is_state_id } from "../State.js";
2
+ import { is_voter_party_type_id } from "./Voter.js";
2
3
  export class VoterTarget {
3
4
  voter_target_id;
4
5
  voter_id;
@@ -8,6 +9,7 @@ export class VoterTarget {
8
9
  federal_congress_district_id;
9
10
  state_legislature_house_district_id;
10
11
  state_legislature_senate_district_id;
12
+ party_type_id;
11
13
  constructor(voter_target) {
12
14
  if (!VoterTarget.is(voter_target)) {
13
15
  throw Error("Invalid input.");
@@ -20,6 +22,7 @@ export class VoterTarget {
20
22
  this.federal_congress_district_id = voter_target.federal_congress_district_id;
21
23
  this.state_legislature_house_district_id = voter_target.state_legislature_house_district_id;
22
24
  this.state_legislature_senate_district_id = voter_target.state_legislature_senate_district_id;
25
+ this.party_type_id = voter_target.party_type_id;
23
26
  }
24
27
  static is(voter_target) {
25
28
  return (voter_target !== undefined &&
@@ -30,6 +33,7 @@ export class VoterTarget {
30
33
  is_state_id(voter_target.state_id) &&
31
34
  typeof voter_target.federal_congress_district_id === "string" &&
32
35
  typeof voter_target.state_legislature_house_district_id === "string" &&
33
- typeof voter_target.state_legislature_senate_district_id === "string");
36
+ typeof voter_target.state_legislature_senate_district_id === "string" &&
37
+ is_voter_party_type_id(voter_target.party_type_id));
34
38
  }
35
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
@@ -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
 
@@ -36,6 +36,8 @@ export class Voter {
36
36
  readonly federal_congress_district_id : string
37
37
  readonly state_legislature_house_district_id : string
38
38
  readonly state_legislature_senate_district_id : string
39
+ readonly party_description? : string
40
+ readonly party_type_id : VoterPartyTypeID
39
41
  readonly occupation_group? : string
40
42
  readonly occupation_description? : string
41
43
  readonly phone_home? : string
@@ -44,8 +46,6 @@ export class Voter {
44
46
  readonly ethnic_group? : string
45
47
  readonly ethnic_description? : string
46
48
  readonly religion_description? : string
47
- readonly party_description? : string
48
- readonly party_type_id? : VoterPartyTypeID
49
49
  readonly language? : string
50
50
  readonly education_level? : string
51
51
  readonly marital_status? : string
@@ -80,6 +80,8 @@ export class Voter {
80
80
  this.federal_congress_district_id = voter.federal_congress_district_id
81
81
  this.state_legislature_house_district_id = voter.state_legislature_house_district_id
82
82
  this.state_legislature_senate_district_id = voter.state_legislature_senate_district_id
83
+ this.party_description = voter.party_description
84
+ this.party_type_id = voter.party_type_id
83
85
  this.occupation_group = voter.occupation_group
84
86
  this.occupation_description = voter.occupation_description
85
87
  this.phone_home = voter.phone_home
@@ -88,8 +90,6 @@ export class Voter {
88
90
  this.ethnic_group = voter.ethnic_group
89
91
  this.ethnic_description = voter.ethnic_description
90
92
  this.religion_description = voter.religion_description
91
- this.party_description = voter.party_description
92
- this.party_type_id = voter.party_type_id
93
93
  this.language = voter.language
94
94
  this.education_level = voter.education_level
95
95
  this.marital_status = voter.marital_status
@@ -123,6 +123,8 @@ export class Voter {
123
123
  typeof voter.federal_congress_district_id === "string" &&
124
124
  typeof voter.state_legislature_house_district_id === "string" &&
125
125
  typeof voter.state_legislature_senate_district_id === "string" &&
126
+ (voter.party_description === undefined || typeof voter.party_description === "string") &&
127
+ is_voter_party_type_id(voter.party_type_id) &&
126
128
  (voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
127
129
  (voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
128
130
  (voter.phone_home === undefined || typeof voter.phone_home === "string") &&
@@ -131,8 +133,6 @@ export class Voter {
131
133
  (voter.ethnic_group === undefined || typeof voter.ethnic_group === "string") &&
132
134
  (voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
133
135
  (voter.religion_description === undefined || typeof voter.religion_description === "string") &&
134
- (voter.party_description === undefined || typeof voter.party_description === "string") &&
135
- (voter.party_type_id === undefined || is_voter_party_type_id(voter.party_type_id)) &&
136
136
  (voter.language === undefined || typeof voter.language === "string") &&
137
137
  (voter.education_level === undefined || typeof voter.education_level === "string") &&
138
138
  (voter.marital_status === undefined || typeof voter.marital_status === "string")
@@ -1,4 +1,5 @@
1
1
  import { is_state_id, StateID } from "../State"
2
+ import { is_voter_party_type_id, VoterPartyTypeID } from "./Voter"
2
3
 
3
4
  export class VoterTarget {
4
5
  readonly voter_target_id : string
@@ -9,6 +10,7 @@ export class VoterTarget {
9
10
  readonly federal_congress_district_id : string
10
11
  readonly state_legislature_house_district_id : string
11
12
  readonly state_legislature_senate_district_id : string
13
+ readonly party_type_id : VoterPartyTypeID
12
14
 
13
15
  constructor(voter_target : any) {
14
16
  if (!VoterTarget.is(voter_target)) {
@@ -22,6 +24,7 @@ export class VoterTarget {
22
24
  this.federal_congress_district_id = voter_target.federal_congress_district_id
23
25
  this.state_legislature_house_district_id = voter_target.state_legislature_house_district_id
24
26
  this.state_legislature_senate_district_id = voter_target.state_legislature_senate_district_id
27
+ this.party_type_id = voter_target.party_type_id
25
28
  }
26
29
 
27
30
  static is(voter_target : any) : voter_target is VoterTarget {
@@ -34,7 +37,8 @@ export class VoterTarget {
34
37
  is_state_id(voter_target.state_id) &&
35
38
  typeof voter_target.federal_congress_district_id === "string" &&
36
39
  typeof voter_target.state_legislature_house_district_id === "string" &&
37
- typeof voter_target.state_legislature_senate_district_id === "string"
40
+ typeof voter_target.state_legislature_senate_district_id === "string" &&
41
+ is_voter_party_type_id(voter_target.party_type_id)
38
42
  )
39
43
  }
40
44
  }