@mailwoman/codex 4.0.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/out/ca/index.d.ts +12 -0
- package/out/ca/index.d.ts.map +1 -0
- package/out/ca/index.js +12 -0
- package/out/ca/index.js.map +1 -0
- package/out/ca/postal-code.d.ts +74 -0
- package/out/ca/postal-code.d.ts.map +1 -0
- package/out/ca/postal-code.js +100 -0
- package/out/ca/postal-code.js.map +1 -0
- package/out/ca/province.d.ts +114 -0
- package/out/ca/province.d.ts.map +1 -0
- package/out/ca/province.js +79 -0
- package/out/ca/province.js.map +1 -0
- package/out/ca/street-type.d.ts +57 -0
- package/out/ca/street-type.d.ts.map +1 -0
- package/out/ca/street-type.js +156 -0
- package/out/ca/street-type.js.map +1 -0
- package/out/de/bundesland.d.ts +124 -0
- package/out/de/bundesland.d.ts.map +1 -0
- package/out/de/bundesland.js +81 -0
- package/out/de/bundesland.js.map +1 -0
- package/out/de/index.d.ts +12 -0
- package/out/de/index.d.ts.map +1 -0
- package/out/de/index.js +12 -0
- package/out/de/index.js.map +1 -0
- package/out/de/postleitzahl.d.ts +108 -0
- package/out/de/postleitzahl.d.ts.map +1 -0
- package/out/de/postleitzahl.js +63 -0
- package/out/de/postleitzahl.js.map +1 -0
- package/out/de/street-type.d.ts +58 -0
- package/out/de/street-type.d.ts.map +1 -0
- package/out/de/street-type.js +79 -0
- package/out/de/street-type.js.map +1 -0
- package/out/fr/code-postal.d.ts +68 -0
- package/out/fr/code-postal.d.ts.map +1 -0
- package/out/fr/code-postal.js +84 -0
- package/out/fr/code-postal.js.map +1 -0
- package/out/fr/departement.d.ts +538 -0
- package/out/fr/departement.d.ts.map +1 -0
- package/out/fr/departement.js +127 -0
- package/out/fr/departement.js.map +1 -0
- package/out/fr/index.d.ts +13 -0
- package/out/fr/index.d.ts.map +1 -0
- package/out/fr/index.js +13 -0
- package/out/fr/index.js.map +1 -0
- package/out/fr/region.d.ts +113 -0
- package/out/fr/region.d.ts.map +1 -0
- package/out/fr/region.js +76 -0
- package/out/fr/region.js.map +1 -0
- package/out/fr/voie.d.ts +64 -0
- package/out/fr/voie.d.ts.map +1 -0
- package/out/fr/voie.js +88 -0
- package/out/fr/voie.js.map +1 -0
- package/out/gb/country.d.ts +51 -0
- package/out/gb/country.d.ts.map +1 -0
- package/out/gb/country.js +56 -0
- package/out/gb/country.js.map +1 -0
- package/out/gb/index.d.ts +14 -0
- package/out/gb/index.d.ts.map +1 -0
- package/out/gb/index.js +14 -0
- package/out/gb/index.js.map +1 -0
- package/out/gb/postcode-area.d.ts +46 -0
- package/out/gb/postcode-area.d.ts.map +1 -0
- package/out/gb/postcode-area.js +101 -0
- package/out/gb/postcode-area.js.map +1 -0
- package/out/gb/postcode.d.ts +73 -0
- package/out/gb/postcode.d.ts.map +1 -0
- package/out/gb/postcode.js +88 -0
- package/out/gb/postcode.js.map +1 -0
- package/out/gb/street-type.d.ts +36 -0
- package/out/gb/street-type.d.ts.map +1 -0
- package/out/gb/street-type.js +86 -0
- package/out/gb/street-type.js.map +1 -0
- package/out/index.d.ts +27 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +27 -0
- package/out/index.js.map +1 -0
- package/out/jp/address-unit.d.ts +72 -0
- package/out/jp/address-unit.d.ts.map +1 -0
- package/out/jp/address-unit.js +78 -0
- package/out/jp/address-unit.js.map +1 -0
- package/out/jp/index.d.ts +13 -0
- package/out/jp/index.d.ts.map +1 -0
- package/out/jp/index.js +13 -0
- package/out/jp/index.js.map +1 -0
- package/out/jp/postal-code.d.ts +63 -0
- package/out/jp/postal-code.d.ts.map +1 -0
- package/out/jp/postal-code.js +77 -0
- package/out/jp/postal-code.js.map +1 -0
- package/out/jp/prefecture.d.ts +347 -0
- package/out/jp/prefecture.d.ts.map +1 -0
- package/out/jp/prefecture.js +147 -0
- package/out/jp/prefecture.js.map +1 -0
- package/out/postcode-systems.d.ts +31 -0
- package/out/postcode-systems.d.ts.map +1 -0
- package/out/postcode-systems.js +58 -0
- package/out/postcode-systems.js.map +1 -0
- package/out/us/index.d.ts +12 -0
- package/out/us/index.d.ts.map +1 -0
- package/out/us/index.js +12 -0
- package/out/us/index.js.map +1 -0
- package/out/us/state.d.ts +26 -0
- package/out/us/state.d.ts.map +1 -0
- package/out/us/state.js +84 -0
- package/out/us/state.js.map +1 -0
- package/out/us/street-suffix.d.ts +499 -0
- package/out/us/street-suffix.d.ts.map +1 -0
- package/out/us/street-suffix.js +313 -0
- package/out/us/street-suffix.js.map +1 -0
- package/out/us/zipcode.d.ts +184 -0
- package/out/us/zipcode.d.ts.map +1 -0
- package/out/us/zipcode.js +127 -0
- package/out/us/zipcode.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The 47 Japanese prefectures (都道府県, todōfuken), keyed by their ISO 3166-2:JP code — the two-digit
|
|
7
|
+
* numeric string `"01"`..`"47"` standing in for `JP-01`..`JP-47`.
|
|
8
|
+
*
|
|
9
|
+
* The contrast with `fr/region.ts`, `de/bundesland.ts`, and `us/state.ts` is in the name itself.
|
|
10
|
+
* "都道府県" is four kanji because the top-level admin unit comes in four legally distinct flavours,
|
|
11
|
+
* even though all 47 are peers in practice:
|
|
12
|
+
*
|
|
13
|
+
* - 都 (to, "metropolis") — exactly **1**: Tokyo (東京都). The capital's special form.
|
|
14
|
+
* - 道 (dō, "circuit") — exactly **1**: Hokkaido (北海道). A historical term; the name already ends in 道,
|
|
15
|
+
* so Hokkaido is written and indexed whole, never stripped to "北海".
|
|
16
|
+
* - 府 (fu, "urban prefecture") — exactly **2**: Osaka (大阪府) and Kyoto (京都府). The old imperial capital
|
|
17
|
+
* region.
|
|
18
|
+
* - 県 (ken, "prefecture") — the remaining **43**. The ordinary case.
|
|
19
|
+
*
|
|
20
|
+
* Unlike a French région or a German Bundesland, the prefecture DOES appear on a normal address
|
|
21
|
+
* line: a Japanese address is written largest-to-smallest (prefecture → city → ward → block), so
|
|
22
|
+
* the prefecture is the first thing written, not an inferred-from-postcode afterthought. See
|
|
23
|
+
* `postal-code.ts` for why the postcode is nonetheless the single most reliable anchor.
|
|
24
|
+
*/
|
|
25
|
+
/** A to/dō/fu/ken classification of the top-level admin unit. */
|
|
26
|
+
export type JapanesePrefectureType = "to" | "do" | "fu" | "ken";
|
|
27
|
+
/** Per-prefecture record: ISO 3166-2:JP numeric code + kanji + romaji + to/dō/fu/ken type. */
|
|
28
|
+
export interface JapanesePrefectureInfo {
|
|
29
|
+
/** ISO 3166-2:JP code without the `JP-` prefix: a two-digit numeric string (`"13"` for `JP-13`). */
|
|
30
|
+
code: string;
|
|
31
|
+
/** Kanji name, including its 都/道/府/県 suffix (e.g. `東京都`). */
|
|
32
|
+
kanji: string;
|
|
33
|
+
/** Macron-free romaji name, suffix-less (e.g. `Tokyo`). */
|
|
34
|
+
romaji: string;
|
|
35
|
+
/** Which of the four flavours of top-level unit this is. */
|
|
36
|
+
type: JapanesePrefectureType;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* ISO 3166-2:JP numeric code → info, for all 47 prefectures. Ordered by code, which is also the
|
|
40
|
+
* conventional north-to-south-ish ordering (Hokkaido `01` at the top, Okinawa `47` at the bottom).
|
|
41
|
+
*/
|
|
42
|
+
export declare const JP_PREFECTURES: {
|
|
43
|
+
readonly "01": {
|
|
44
|
+
readonly code: "01";
|
|
45
|
+
readonly kanji: "北海道";
|
|
46
|
+
readonly romaji: "Hokkaido";
|
|
47
|
+
readonly type: "do";
|
|
48
|
+
};
|
|
49
|
+
readonly "02": {
|
|
50
|
+
readonly code: "02";
|
|
51
|
+
readonly kanji: "青森県";
|
|
52
|
+
readonly romaji: "Aomori";
|
|
53
|
+
readonly type: "ken";
|
|
54
|
+
};
|
|
55
|
+
readonly "03": {
|
|
56
|
+
readonly code: "03";
|
|
57
|
+
readonly kanji: "岩手県";
|
|
58
|
+
readonly romaji: "Iwate";
|
|
59
|
+
readonly type: "ken";
|
|
60
|
+
};
|
|
61
|
+
readonly "04": {
|
|
62
|
+
readonly code: "04";
|
|
63
|
+
readonly kanji: "宮城県";
|
|
64
|
+
readonly romaji: "Miyagi";
|
|
65
|
+
readonly type: "ken";
|
|
66
|
+
};
|
|
67
|
+
readonly "05": {
|
|
68
|
+
readonly code: "05";
|
|
69
|
+
readonly kanji: "秋田県";
|
|
70
|
+
readonly romaji: "Akita";
|
|
71
|
+
readonly type: "ken";
|
|
72
|
+
};
|
|
73
|
+
readonly "06": {
|
|
74
|
+
readonly code: "06";
|
|
75
|
+
readonly kanji: "山形県";
|
|
76
|
+
readonly romaji: "Yamagata";
|
|
77
|
+
readonly type: "ken";
|
|
78
|
+
};
|
|
79
|
+
readonly "07": {
|
|
80
|
+
readonly code: "07";
|
|
81
|
+
readonly kanji: "福島県";
|
|
82
|
+
readonly romaji: "Fukushima";
|
|
83
|
+
readonly type: "ken";
|
|
84
|
+
};
|
|
85
|
+
readonly "08": {
|
|
86
|
+
readonly code: "08";
|
|
87
|
+
readonly kanji: "茨城県";
|
|
88
|
+
readonly romaji: "Ibaraki";
|
|
89
|
+
readonly type: "ken";
|
|
90
|
+
};
|
|
91
|
+
readonly "09": {
|
|
92
|
+
readonly code: "09";
|
|
93
|
+
readonly kanji: "栃木県";
|
|
94
|
+
readonly romaji: "Tochigi";
|
|
95
|
+
readonly type: "ken";
|
|
96
|
+
};
|
|
97
|
+
readonly "10": {
|
|
98
|
+
readonly code: "10";
|
|
99
|
+
readonly kanji: "群馬県";
|
|
100
|
+
readonly romaji: "Gunma";
|
|
101
|
+
readonly type: "ken";
|
|
102
|
+
};
|
|
103
|
+
readonly "11": {
|
|
104
|
+
readonly code: "11";
|
|
105
|
+
readonly kanji: "埼玉県";
|
|
106
|
+
readonly romaji: "Saitama";
|
|
107
|
+
readonly type: "ken";
|
|
108
|
+
};
|
|
109
|
+
readonly "12": {
|
|
110
|
+
readonly code: "12";
|
|
111
|
+
readonly kanji: "千葉県";
|
|
112
|
+
readonly romaji: "Chiba";
|
|
113
|
+
readonly type: "ken";
|
|
114
|
+
};
|
|
115
|
+
readonly "13": {
|
|
116
|
+
readonly code: "13";
|
|
117
|
+
readonly kanji: "東京都";
|
|
118
|
+
readonly romaji: "Tokyo";
|
|
119
|
+
readonly type: "to";
|
|
120
|
+
};
|
|
121
|
+
readonly "14": {
|
|
122
|
+
readonly code: "14";
|
|
123
|
+
readonly kanji: "神奈川県";
|
|
124
|
+
readonly romaji: "Kanagawa";
|
|
125
|
+
readonly type: "ken";
|
|
126
|
+
};
|
|
127
|
+
readonly "15": {
|
|
128
|
+
readonly code: "15";
|
|
129
|
+
readonly kanji: "新潟県";
|
|
130
|
+
readonly romaji: "Niigata";
|
|
131
|
+
readonly type: "ken";
|
|
132
|
+
};
|
|
133
|
+
readonly "16": {
|
|
134
|
+
readonly code: "16";
|
|
135
|
+
readonly kanji: "富山県";
|
|
136
|
+
readonly romaji: "Toyama";
|
|
137
|
+
readonly type: "ken";
|
|
138
|
+
};
|
|
139
|
+
readonly "17": {
|
|
140
|
+
readonly code: "17";
|
|
141
|
+
readonly kanji: "石川県";
|
|
142
|
+
readonly romaji: "Ishikawa";
|
|
143
|
+
readonly type: "ken";
|
|
144
|
+
};
|
|
145
|
+
readonly "18": {
|
|
146
|
+
readonly code: "18";
|
|
147
|
+
readonly kanji: "福井県";
|
|
148
|
+
readonly romaji: "Fukui";
|
|
149
|
+
readonly type: "ken";
|
|
150
|
+
};
|
|
151
|
+
readonly "19": {
|
|
152
|
+
readonly code: "19";
|
|
153
|
+
readonly kanji: "山梨県";
|
|
154
|
+
readonly romaji: "Yamanashi";
|
|
155
|
+
readonly type: "ken";
|
|
156
|
+
};
|
|
157
|
+
readonly "20": {
|
|
158
|
+
readonly code: "20";
|
|
159
|
+
readonly kanji: "長野県";
|
|
160
|
+
readonly romaji: "Nagano";
|
|
161
|
+
readonly type: "ken";
|
|
162
|
+
};
|
|
163
|
+
readonly "21": {
|
|
164
|
+
readonly code: "21";
|
|
165
|
+
readonly kanji: "岐阜県";
|
|
166
|
+
readonly romaji: "Gifu";
|
|
167
|
+
readonly type: "ken";
|
|
168
|
+
};
|
|
169
|
+
readonly "22": {
|
|
170
|
+
readonly code: "22";
|
|
171
|
+
readonly kanji: "静岡県";
|
|
172
|
+
readonly romaji: "Shizuoka";
|
|
173
|
+
readonly type: "ken";
|
|
174
|
+
};
|
|
175
|
+
readonly "23": {
|
|
176
|
+
readonly code: "23";
|
|
177
|
+
readonly kanji: "愛知県";
|
|
178
|
+
readonly romaji: "Aichi";
|
|
179
|
+
readonly type: "ken";
|
|
180
|
+
};
|
|
181
|
+
readonly "24": {
|
|
182
|
+
readonly code: "24";
|
|
183
|
+
readonly kanji: "三重県";
|
|
184
|
+
readonly romaji: "Mie";
|
|
185
|
+
readonly type: "ken";
|
|
186
|
+
};
|
|
187
|
+
readonly "25": {
|
|
188
|
+
readonly code: "25";
|
|
189
|
+
readonly kanji: "滋賀県";
|
|
190
|
+
readonly romaji: "Shiga";
|
|
191
|
+
readonly type: "ken";
|
|
192
|
+
};
|
|
193
|
+
readonly "26": {
|
|
194
|
+
readonly code: "26";
|
|
195
|
+
readonly kanji: "京都府";
|
|
196
|
+
readonly romaji: "Kyoto";
|
|
197
|
+
readonly type: "fu";
|
|
198
|
+
};
|
|
199
|
+
readonly "27": {
|
|
200
|
+
readonly code: "27";
|
|
201
|
+
readonly kanji: "大阪府";
|
|
202
|
+
readonly romaji: "Osaka";
|
|
203
|
+
readonly type: "fu";
|
|
204
|
+
};
|
|
205
|
+
readonly "28": {
|
|
206
|
+
readonly code: "28";
|
|
207
|
+
readonly kanji: "兵庫県";
|
|
208
|
+
readonly romaji: "Hyogo";
|
|
209
|
+
readonly type: "ken";
|
|
210
|
+
};
|
|
211
|
+
readonly "29": {
|
|
212
|
+
readonly code: "29";
|
|
213
|
+
readonly kanji: "奈良県";
|
|
214
|
+
readonly romaji: "Nara";
|
|
215
|
+
readonly type: "ken";
|
|
216
|
+
};
|
|
217
|
+
readonly "30": {
|
|
218
|
+
readonly code: "30";
|
|
219
|
+
readonly kanji: "和歌山県";
|
|
220
|
+
readonly romaji: "Wakayama";
|
|
221
|
+
readonly type: "ken";
|
|
222
|
+
};
|
|
223
|
+
readonly "31": {
|
|
224
|
+
readonly code: "31";
|
|
225
|
+
readonly kanji: "鳥取県";
|
|
226
|
+
readonly romaji: "Tottori";
|
|
227
|
+
readonly type: "ken";
|
|
228
|
+
};
|
|
229
|
+
readonly "32": {
|
|
230
|
+
readonly code: "32";
|
|
231
|
+
readonly kanji: "島根県";
|
|
232
|
+
readonly romaji: "Shimane";
|
|
233
|
+
readonly type: "ken";
|
|
234
|
+
};
|
|
235
|
+
readonly "33": {
|
|
236
|
+
readonly code: "33";
|
|
237
|
+
readonly kanji: "岡山県";
|
|
238
|
+
readonly romaji: "Okayama";
|
|
239
|
+
readonly type: "ken";
|
|
240
|
+
};
|
|
241
|
+
readonly "34": {
|
|
242
|
+
readonly code: "34";
|
|
243
|
+
readonly kanji: "広島県";
|
|
244
|
+
readonly romaji: "Hiroshima";
|
|
245
|
+
readonly type: "ken";
|
|
246
|
+
};
|
|
247
|
+
readonly "35": {
|
|
248
|
+
readonly code: "35";
|
|
249
|
+
readonly kanji: "山口県";
|
|
250
|
+
readonly romaji: "Yamaguchi";
|
|
251
|
+
readonly type: "ken";
|
|
252
|
+
};
|
|
253
|
+
readonly "36": {
|
|
254
|
+
readonly code: "36";
|
|
255
|
+
readonly kanji: "徳島県";
|
|
256
|
+
readonly romaji: "Tokushima";
|
|
257
|
+
readonly type: "ken";
|
|
258
|
+
};
|
|
259
|
+
readonly "37": {
|
|
260
|
+
readonly code: "37";
|
|
261
|
+
readonly kanji: "香川県";
|
|
262
|
+
readonly romaji: "Kagawa";
|
|
263
|
+
readonly type: "ken";
|
|
264
|
+
};
|
|
265
|
+
readonly "38": {
|
|
266
|
+
readonly code: "38";
|
|
267
|
+
readonly kanji: "愛媛県";
|
|
268
|
+
readonly romaji: "Ehime";
|
|
269
|
+
readonly type: "ken";
|
|
270
|
+
};
|
|
271
|
+
readonly "39": {
|
|
272
|
+
readonly code: "39";
|
|
273
|
+
readonly kanji: "高知県";
|
|
274
|
+
readonly romaji: "Kochi";
|
|
275
|
+
readonly type: "ken";
|
|
276
|
+
};
|
|
277
|
+
readonly "40": {
|
|
278
|
+
readonly code: "40";
|
|
279
|
+
readonly kanji: "福岡県";
|
|
280
|
+
readonly romaji: "Fukuoka";
|
|
281
|
+
readonly type: "ken";
|
|
282
|
+
};
|
|
283
|
+
readonly "41": {
|
|
284
|
+
readonly code: "41";
|
|
285
|
+
readonly kanji: "佐賀県";
|
|
286
|
+
readonly romaji: "Saga";
|
|
287
|
+
readonly type: "ken";
|
|
288
|
+
};
|
|
289
|
+
readonly "42": {
|
|
290
|
+
readonly code: "42";
|
|
291
|
+
readonly kanji: "長崎県";
|
|
292
|
+
readonly romaji: "Nagasaki";
|
|
293
|
+
readonly type: "ken";
|
|
294
|
+
};
|
|
295
|
+
readonly "43": {
|
|
296
|
+
readonly code: "43";
|
|
297
|
+
readonly kanji: "熊本県";
|
|
298
|
+
readonly romaji: "Kumamoto";
|
|
299
|
+
readonly type: "ken";
|
|
300
|
+
};
|
|
301
|
+
readonly "44": {
|
|
302
|
+
readonly code: "44";
|
|
303
|
+
readonly kanji: "大分県";
|
|
304
|
+
readonly romaji: "Oita";
|
|
305
|
+
readonly type: "ken";
|
|
306
|
+
};
|
|
307
|
+
readonly "45": {
|
|
308
|
+
readonly code: "45";
|
|
309
|
+
readonly kanji: "宮崎県";
|
|
310
|
+
readonly romaji: "Miyazaki";
|
|
311
|
+
readonly type: "ken";
|
|
312
|
+
};
|
|
313
|
+
readonly "46": {
|
|
314
|
+
readonly code: "46";
|
|
315
|
+
readonly kanji: "鹿児島県";
|
|
316
|
+
readonly romaji: "Kagoshima";
|
|
317
|
+
readonly type: "ken";
|
|
318
|
+
};
|
|
319
|
+
readonly "47": {
|
|
320
|
+
readonly code: "47";
|
|
321
|
+
readonly kanji: "沖縄県";
|
|
322
|
+
readonly romaji: "Okinawa";
|
|
323
|
+
readonly type: "ken";
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
/** An ISO 3166-2:JP prefecture code (`"01"`..`"47"`). */
|
|
327
|
+
export type JapanesePrefectureCode = keyof typeof JP_PREFECTURES;
|
|
328
|
+
/** Type-predicate for an ISO 3166-2:JP prefecture code (`"01"`..`"47"`). */
|
|
329
|
+
export declare function isJapanesePrefectureCode(input: unknown): input is JapanesePrefectureCode;
|
|
330
|
+
/**
|
|
331
|
+
* Folded romaji / kanji surface form → ISO 3166-2:JP code. Every prefecture contributes several
|
|
332
|
+
* keys: the macron-folded romaji (and the suffixed `name-ken` form folds to the same key), the full
|
|
333
|
+
* kanji (`東京都`), and the suffix-less kanji (`東京`). Hokkaido keeps its 道 in both kanji keys.
|
|
334
|
+
*/
|
|
335
|
+
export declare const JP_PREFECTURE_NAME_TO_CODE: ReadonlyMap<string, JapanesePrefectureCode>;
|
|
336
|
+
/**
|
|
337
|
+
* Resolve a Japanese prefecture surface form to its ISO 3166-2:JP code, accepting:
|
|
338
|
+
*
|
|
339
|
+
* - A code directly (`"13"` → `"13"`),
|
|
340
|
+
* - A romaji name, case-insensitive, macrons optional, with OR without the romaji type-suffix
|
|
341
|
+
* (`Tōkyō` / `Tokyo` / `tokyo` / `Tokyo-to` → `"13"`),
|
|
342
|
+
* - A kanji name, with or without its 都/道/府/県 suffix (`東京都` / `東京` → `"13"`).
|
|
343
|
+
*
|
|
344
|
+
* Returns null for anything it cannot place.
|
|
345
|
+
*/
|
|
346
|
+
export declare function lookupJapanesePrefecture(input: string | null | undefined): JapanesePrefectureCode | null;
|
|
347
|
+
//# sourceMappingURL=prefecture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefecture.d.ts","source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
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The 47 Japanese prefectures (都道府県, todōfuken), keyed by their ISO 3166-2:JP code — the two-digit
|
|
7
|
+
* numeric string `"01"`..`"47"` standing in for `JP-01`..`JP-47`.
|
|
8
|
+
*
|
|
9
|
+
* The contrast with `fr/region.ts`, `de/bundesland.ts`, and `us/state.ts` is in the name itself.
|
|
10
|
+
* "都道府県" is four kanji because the top-level admin unit comes in four legally distinct flavours,
|
|
11
|
+
* even though all 47 are peers in practice:
|
|
12
|
+
*
|
|
13
|
+
* - 都 (to, "metropolis") — exactly **1**: Tokyo (東京都). The capital's special form.
|
|
14
|
+
* - 道 (dō, "circuit") — exactly **1**: Hokkaido (北海道). A historical term; the name already ends in 道,
|
|
15
|
+
* so Hokkaido is written and indexed whole, never stripped to "北海".
|
|
16
|
+
* - 府 (fu, "urban prefecture") — exactly **2**: Osaka (大阪府) and Kyoto (京都府). The old imperial capital
|
|
17
|
+
* region.
|
|
18
|
+
* - 県 (ken, "prefecture") — the remaining **43**. The ordinary case.
|
|
19
|
+
*
|
|
20
|
+
* Unlike a French région or a German Bundesland, the prefecture DOES appear on a normal address
|
|
21
|
+
* line: a Japanese address is written largest-to-smallest (prefecture → city → ward → block), so
|
|
22
|
+
* the prefecture is the first thing written, not an inferred-from-postcode afterthought. See
|
|
23
|
+
* `postal-code.ts` for why the postcode is nonetheless the single most reliable anchor.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* ISO 3166-2:JP numeric code → info, for all 47 prefectures. Ordered by code, which is also the
|
|
27
|
+
* conventional north-to-south-ish ordering (Hokkaido `01` at the top, Okinawa `47` at the bottom).
|
|
28
|
+
*/
|
|
29
|
+
export const JP_PREFECTURES = {
|
|
30
|
+
"01": { code: "01", kanji: "北海道", romaji: "Hokkaido", type: "do" },
|
|
31
|
+
"02": { code: "02", kanji: "青森県", romaji: "Aomori", type: "ken" },
|
|
32
|
+
"03": { code: "03", kanji: "岩手県", romaji: "Iwate", type: "ken" },
|
|
33
|
+
"04": { code: "04", kanji: "宮城県", romaji: "Miyagi", type: "ken" },
|
|
34
|
+
"05": { code: "05", kanji: "秋田県", romaji: "Akita", type: "ken" },
|
|
35
|
+
"06": { code: "06", kanji: "山形県", romaji: "Yamagata", type: "ken" },
|
|
36
|
+
"07": { code: "07", kanji: "福島県", romaji: "Fukushima", type: "ken" },
|
|
37
|
+
"08": { code: "08", kanji: "茨城県", romaji: "Ibaraki", type: "ken" },
|
|
38
|
+
"09": { code: "09", kanji: "栃木県", romaji: "Tochigi", type: "ken" },
|
|
39
|
+
"10": { code: "10", kanji: "群馬県", romaji: "Gunma", type: "ken" },
|
|
40
|
+
"11": { code: "11", kanji: "埼玉県", romaji: "Saitama", type: "ken" },
|
|
41
|
+
"12": { code: "12", kanji: "千葉県", romaji: "Chiba", type: "ken" },
|
|
42
|
+
"13": { code: "13", kanji: "東京都", romaji: "Tokyo", type: "to" },
|
|
43
|
+
"14": { code: "14", kanji: "神奈川県", romaji: "Kanagawa", type: "ken" },
|
|
44
|
+
"15": { code: "15", kanji: "新潟県", romaji: "Niigata", type: "ken" },
|
|
45
|
+
"16": { code: "16", kanji: "富山県", romaji: "Toyama", type: "ken" },
|
|
46
|
+
"17": { code: "17", kanji: "石川県", romaji: "Ishikawa", type: "ken" },
|
|
47
|
+
"18": { code: "18", kanji: "福井県", romaji: "Fukui", type: "ken" },
|
|
48
|
+
"19": { code: "19", kanji: "山梨県", romaji: "Yamanashi", type: "ken" },
|
|
49
|
+
"20": { code: "20", kanji: "長野県", romaji: "Nagano", type: "ken" },
|
|
50
|
+
"21": { code: "21", kanji: "岐阜県", romaji: "Gifu", type: "ken" },
|
|
51
|
+
"22": { code: "22", kanji: "静岡県", romaji: "Shizuoka", type: "ken" },
|
|
52
|
+
"23": { code: "23", kanji: "愛知県", romaji: "Aichi", type: "ken" },
|
|
53
|
+
"24": { code: "24", kanji: "三重県", romaji: "Mie", type: "ken" },
|
|
54
|
+
"25": { code: "25", kanji: "滋賀県", romaji: "Shiga", type: "ken" },
|
|
55
|
+
"26": { code: "26", kanji: "京都府", romaji: "Kyoto", type: "fu" },
|
|
56
|
+
"27": { code: "27", kanji: "大阪府", romaji: "Osaka", type: "fu" },
|
|
57
|
+
"28": { code: "28", kanji: "兵庫県", romaji: "Hyogo", type: "ken" },
|
|
58
|
+
"29": { code: "29", kanji: "奈良県", romaji: "Nara", type: "ken" },
|
|
59
|
+
"30": { code: "30", kanji: "和歌山県", romaji: "Wakayama", type: "ken" },
|
|
60
|
+
"31": { code: "31", kanji: "鳥取県", romaji: "Tottori", type: "ken" },
|
|
61
|
+
"32": { code: "32", kanji: "島根県", romaji: "Shimane", type: "ken" },
|
|
62
|
+
"33": { code: "33", kanji: "岡山県", romaji: "Okayama", type: "ken" },
|
|
63
|
+
"34": { code: "34", kanji: "広島県", romaji: "Hiroshima", type: "ken" },
|
|
64
|
+
"35": { code: "35", kanji: "山口県", romaji: "Yamaguchi", type: "ken" },
|
|
65
|
+
"36": { code: "36", kanji: "徳島県", romaji: "Tokushima", type: "ken" },
|
|
66
|
+
"37": { code: "37", kanji: "香川県", romaji: "Kagawa", type: "ken" },
|
|
67
|
+
"38": { code: "38", kanji: "愛媛県", romaji: "Ehime", type: "ken" },
|
|
68
|
+
"39": { code: "39", kanji: "高知県", romaji: "Kochi", type: "ken" },
|
|
69
|
+
"40": { code: "40", kanji: "福岡県", romaji: "Fukuoka", type: "ken" },
|
|
70
|
+
"41": { code: "41", kanji: "佐賀県", romaji: "Saga", type: "ken" },
|
|
71
|
+
"42": { code: "42", kanji: "長崎県", romaji: "Nagasaki", type: "ken" },
|
|
72
|
+
"43": { code: "43", kanji: "熊本県", romaji: "Kumamoto", type: "ken" },
|
|
73
|
+
"44": { code: "44", kanji: "大分県", romaji: "Oita", type: "ken" },
|
|
74
|
+
"45": { code: "45", kanji: "宮崎県", romaji: "Miyazaki", type: "ken" },
|
|
75
|
+
"46": { code: "46", kanji: "鹿児島県", romaji: "Kagoshima", type: "ken" },
|
|
76
|
+
"47": { code: "47", kanji: "沖縄県", romaji: "Okinawa", type: "ken" },
|
|
77
|
+
};
|
|
78
|
+
const PREFECTURE_CODE_SET = new Set(Object.keys(JP_PREFECTURES));
|
|
79
|
+
/** Type-predicate for an ISO 3166-2:JP prefecture code (`"01"`..`"47"`). */
|
|
80
|
+
export function isJapanesePrefectureCode(input) {
|
|
81
|
+
return typeof input === "string" && PREFECTURE_CODE_SET.has(input);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fold a romaji surface form so `Tōkyō`, `Tokyo`, and `Tokyo-to` all key alike: strip macrons (NFD
|
|
85
|
+
*
|
|
86
|
+
* - Drop the combining marks), lowercase, peel off an appended `-to`/`-do`/`-fu`/`-ken` type-suffix,
|
|
87
|
+
* then drop everything but `a-z`. `Tōkyō-to` and `tokyo` both → `tokyo`.
|
|
88
|
+
*
|
|
89
|
+
* The suffix is only stripped when it is a genuine appendage — separated by a
|
|
90
|
+
* hyphen/space/middle-dot (`Tokyo-to`, `Osaka fu`) or trailing the macron-bearing long-vowel form.
|
|
91
|
+
* That guard is load-bearing: four bare romaji names already END in a suffix syllable (Kyo**to**,
|
|
92
|
+
* Gi**fu**, Hokkai**do**, Kumamo**to**), and a blind trailing-strip would maim them. We never strip
|
|
93
|
+
* from an unseparated bare name, so `kyoto` stays `kyoto`.
|
|
94
|
+
*/
|
|
95
|
+
function foldRomaji(s) {
|
|
96
|
+
const lowered = s
|
|
97
|
+
.toLowerCase()
|
|
98
|
+
.normalize("NFD")
|
|
99
|
+
.replace(/[\u0300-\u036f]/g, "");
|
|
100
|
+
// Strip an appended type-suffix only when a separator (hyphen / space / middle dot) precedes it.
|
|
101
|
+
const desuffixed = lowered.replace(/[-\s·][\s]*(to|do|fu|ken)$/, "");
|
|
102
|
+
return desuffixed.replace(/[^a-z]/g, "");
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Strip the trailing 都/道/府/県 admin kanji from a prefecture name (`東京都` → `東京`). Hokkaido is the
|
|
106
|
+
* exception: `北海道` ends in 道 but is a single indivisible name, so it is left whole.
|
|
107
|
+
*/
|
|
108
|
+
function stripKanjiSuffix(kanji) {
|
|
109
|
+
if (kanji === "北海道")
|
|
110
|
+
return kanji;
|
|
111
|
+
return kanji.replace(/[都道府県]$/, "");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Folded romaji / kanji surface form → ISO 3166-2:JP code. Every prefecture contributes several
|
|
115
|
+
* keys: the macron-folded romaji (and the suffixed `name-ken` form folds to the same key), the full
|
|
116
|
+
* kanji (`東京都`), and the suffix-less kanji (`東京`). Hokkaido keeps its 道 in both kanji keys.
|
|
117
|
+
*/
|
|
118
|
+
export const JP_PREFECTURE_NAME_TO_CODE = (() => {
|
|
119
|
+
const out = new Map();
|
|
120
|
+
for (const code of Object.keys(JP_PREFECTURES)) {
|
|
121
|
+
const info = JP_PREFECTURES[code];
|
|
122
|
+
out.set(foldRomaji(info.romaji), code);
|
|
123
|
+
out.set(info.kanji, code);
|
|
124
|
+
out.set(stripKanjiSuffix(info.kanji), code);
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
})();
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a Japanese prefecture surface form to its ISO 3166-2:JP code, accepting:
|
|
130
|
+
*
|
|
131
|
+
* - A code directly (`"13"` → `"13"`),
|
|
132
|
+
* - A romaji name, case-insensitive, macrons optional, with OR without the romaji type-suffix
|
|
133
|
+
* (`Tōkyō` / `Tokyo` / `tokyo` / `Tokyo-to` → `"13"`),
|
|
134
|
+
* - A kanji name, with or without its 都/道/府/県 suffix (`東京都` / `東京` → `"13"`).
|
|
135
|
+
*
|
|
136
|
+
* Returns null for anything it cannot place.
|
|
137
|
+
*/
|
|
138
|
+
export function lookupJapanesePrefecture(input) {
|
|
139
|
+
if (!input || typeof input !== "string")
|
|
140
|
+
return null;
|
|
141
|
+
const trimmed = input.trim();
|
|
142
|
+
if (PREFECTURE_CODE_SET.has(trimmed))
|
|
143
|
+
return trimmed;
|
|
144
|
+
// Try kanji first (exact, then suffix-less), then fall back to the macron-folded romaji.
|
|
145
|
+
return JP_PREFECTURE_NAME_TO_CODE.get(trimmed) ?? JP_PREFECTURE_NAME_TO_CODE.get(foldRomaji(trimmed)) ?? null;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=prefecture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefecture.js","sourceRoot":"","sources":["../../jp/prefecture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAiBH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE;IAClE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;IACjE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;IAChE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;IACjE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;IAChE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE;IACnE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,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAC,EAAE,CAAA;AAEJ;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAgC;IACxE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACpD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC5B,IAAI,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,OAAiC,CAAA;IAC9E,yFAAyF;IACzF,OAAO,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAA;AAC9G,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The inverse of the per-slice postcode patterns: given a postcode string, which address SYSTEMS
|
|
7
|
+
* could it belong to? Each codex slice owns its own postcode shape (`us` accepts
|
|
8
|
+
* `\d{5}(-\d{4})?`, `ca` accepts `A1A 1A1`, `jp` accepts `NNN-NNNN`, …); this is the single place
|
|
9
|
+
* that asks all of them at once and collects the matches.
|
|
10
|
+
*
|
|
11
|
+
* It is the shared source of truth for "which systems can this shape be" — consumed by the postcode
|
|
12
|
+
* anchor (to narrow which systems' street vocabularies it checks) and, in time, by the runtime
|
|
13
|
+
* pipeline's locale gate (so its format→locale scoring derives from the same patterns rather than
|
|
14
|
+
* a second, divergent copy). The point is to unify the DATA, not to couple the modules: callers
|
|
15
|
+
* depend on this pure function, never on each other.
|
|
16
|
+
*
|
|
17
|
+
* Note this is a SHAPE test, not a gazetteer-membership test. A bare `68161` matches the US,
|
|
18
|
+
* German, AND French 5-digit shapes, so it returns `["us", "de", "fr"]` — the shape alone cannot
|
|
19
|
+
* split the numeric-postcode systems. The anchor uses real gazetteer membership for the finer
|
|
20
|
+
* call; this function answers the coarser, model-free "which systems is this shape even eligible
|
|
21
|
+
* for".
|
|
22
|
+
*/
|
|
23
|
+
/** A codex address-system code — the subpath under `@mailwoman/codex/<system>`. */
|
|
24
|
+
export type SystemCode = "us" | "de" | "fr" | "ca" | "gb" | "jp";
|
|
25
|
+
/**
|
|
26
|
+
* Every address system whose own postcode shape accepts `postcode`. Empty when no system recognizes
|
|
27
|
+
* the shape (e.g. a bare `27`, or a 7-digit run). O(number of systems) — a handful of cheap regex
|
|
28
|
+
* tests, run only on the few postcode-shaped spans an address contains.
|
|
29
|
+
*/
|
|
30
|
+
export declare function candidateSystemsForPostcode(postcode: string): SystemCode[];
|
|
31
|
+
//# sourceMappingURL=postcode-systems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-systems.d.ts","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAiBhE;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CAO1E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The inverse of the per-slice postcode patterns: given a postcode string, which address SYSTEMS
|
|
7
|
+
* could it belong to? Each codex slice owns its own postcode shape (`us` accepts
|
|
8
|
+
* `\d{5}(-\d{4})?`, `ca` accepts `A1A 1A1`, `jp` accepts `NNN-NNNN`, …); this is the single place
|
|
9
|
+
* that asks all of them at once and collects the matches.
|
|
10
|
+
*
|
|
11
|
+
* It is the shared source of truth for "which systems can this shape be" — consumed by the postcode
|
|
12
|
+
* anchor (to narrow which systems' street vocabularies it checks) and, in time, by the runtime
|
|
13
|
+
* pipeline's locale gate (so its format→locale scoring derives from the same patterns rather than
|
|
14
|
+
* a second, divergent copy). The point is to unify the DATA, not to couple the modules: callers
|
|
15
|
+
* depend on this pure function, never on each other.
|
|
16
|
+
*
|
|
17
|
+
* Note this is a SHAPE test, not a gazetteer-membership test. A bare `68161` matches the US,
|
|
18
|
+
* German, AND French 5-digit shapes, so it returns `["us", "de", "fr"]` — the shape alone cannot
|
|
19
|
+
* split the numeric-postcode systems. The anchor uses real gazetteer membership for the finer
|
|
20
|
+
* call; this function answers the coarser, model-free "which systems is this shape even eligible
|
|
21
|
+
* for".
|
|
22
|
+
*/
|
|
23
|
+
import { normalizeCaPostalCode } from "./ca/index.js";
|
|
24
|
+
import { normalizePLZ } from "./de/index.js";
|
|
25
|
+
import { normalizeCodePostal } from "./fr/index.js";
|
|
26
|
+
import { normalizeUkPostcode } from "./gb/index.js";
|
|
27
|
+
import { normalizeJpPostalCode } from "./jp/index.js";
|
|
28
|
+
import { isZipCode } from "./us/index.js";
|
|
29
|
+
/**
|
|
30
|
+
* Per-system membership test: each entry returns true when the string is accepted by that system's
|
|
31
|
+
* own postcode shape (after that system's normalization — so `D-68161` reaches `de`, `1012 LM`
|
|
32
|
+
* reaches nothing here since NL has no slice yet, etc.). Ordered for a stable, alphabetical-ish
|
|
33
|
+
* result.
|
|
34
|
+
*/
|
|
35
|
+
const SYSTEM_ACCEPTS = [
|
|
36
|
+
["us", (s) => isZipCode(s)],
|
|
37
|
+
["de", (s) => normalizePLZ(s) !== null],
|
|
38
|
+
["fr", (s) => normalizeCodePostal(s) !== null],
|
|
39
|
+
["ca", (s) => normalizeCaPostalCode(s) !== null],
|
|
40
|
+
["gb", (s) => normalizeUkPostcode(s) !== null],
|
|
41
|
+
["jp", (s) => normalizeJpPostalCode(s) !== null],
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Every address system whose own postcode shape accepts `postcode`. Empty when no system recognizes
|
|
45
|
+
* the shape (e.g. a bare `27`, or a 7-digit run). O(number of systems) — a handful of cheap regex
|
|
46
|
+
* tests, run only on the few postcode-shaped spans an address contains.
|
|
47
|
+
*/
|
|
48
|
+
export function candidateSystemsForPostcode(postcode) {
|
|
49
|
+
if (typeof postcode !== "string" || postcode.length === 0)
|
|
50
|
+
return [];
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const [system, accepts] of SYSTEM_ACCEPTS) {
|
|
53
|
+
if (accepts(postcode))
|
|
54
|
+
out.push(system);
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=postcode-systems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-systems.js","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAKzC;;;;;GAKG;AACH,MAAM,cAAc,GAAiE;IACpF,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACvC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9C,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChD,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9C,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAChD,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB;IAC3D,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACpE,MAAM,GAAG,GAAiB,EAAE,CAAA;IAC5B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,EAAE,CAAC;QAChD,IAAI,OAAO,CAAC,QAAQ,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The United States address system (USPS): street suffixes, ZIP codes, and the state abbreviations
|
|
7
|
+
* they hang off of.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./state.js";
|
|
10
|
+
export * from "./street-suffix.js";
|
|
11
|
+
export * from "./zipcode.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../us/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA"}
|
package/out/us/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The United States address system (USPS): street suffixes, ZIP codes, and the state abbreviations
|
|
7
|
+
* they hang off of.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./state.js";
|
|
10
|
+
export * from "./street-suffix.js";
|
|
11
|
+
export * from "./zipcode.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../us/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA"}
|