@finbheara/domain 0.41.0 → 0.42.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.
@@ -7501,14 +7501,7 @@ function createPlaceReader2(options = {}) {
7501
7501
  const listedPhrases = new Set;
7502
7502
  const byHeading = new Map;
7503
7503
  const byRunPrint = new Map;
7504
- const byGeneric = new Map;
7505
7504
  for (const n of source) {
7506
- if (n.kind === "city")
7507
- for (const p of [n.name, ...n.prints]) {
7508
- const k = genericKey2(fold(p));
7509
- if (k !== undefined)
7510
- push(byGeneric, k, n);
7511
- }
7512
7505
  for (const h of n.headings ?? [])
7513
7506
  push(byHeading, fold(h), n);
7514
7507
  for (const r of n.runPrints ?? [])
@@ -7516,11 +7509,12 @@ function createPlaceReader2(options = {}) {
7516
7509
  push(byPrint, fold(n.id), n);
7517
7510
  if (n.kind !== "body")
7518
7511
  push(byPrint, fold(n.name), n);
7519
- for (const p of n.prints)
7520
- push(byPrint, fold(p), n);
7521
- for (const p of n.prints)
7522
- if (fold(p).includes(" "))
7523
- listedPhrases.add(fold(p));
7512
+ for (const p of n.prints) {
7513
+ const f = fold(p);
7514
+ push(byPrint, f, n);
7515
+ if (f.includes(" "))
7516
+ listedPhrases.add(f);
7517
+ }
7524
7518
  for (const c of n.codes)
7525
7519
  push(byCode, c, n);
7526
7520
  for (const t of n.truncations ?? [])
@@ -7572,9 +7566,15 @@ function createPlaceReader2(options = {}) {
7572
7566
  }
7573
7567
  return out;
7574
7568
  };
7575
- const parents = new Map;
7576
- for (const n of source)
7577
- parents.set(n.id, upOf(n));
7569
+ let parents;
7570
+ const graph = () => {
7571
+ if (parents !== undefined)
7572
+ return parents;
7573
+ parents = new Map;
7574
+ for (const n of source)
7575
+ parents.set(n.id, upOf(n));
7576
+ return parents;
7577
+ };
7578
7578
  const countryOnMap = (n) => {
7579
7579
  const seen = new Set;
7580
7580
  for (let at = n;at !== undefined && !seen.has(at.id); ) {
@@ -7598,8 +7598,15 @@ function createPlaceReader2(options = {}) {
7598
7598
  }
7599
7599
  return;
7600
7600
  };
7601
- const ancestorsOf = new Map;
7602
- for (const n of source) {
7601
+ const ancestors = new Map;
7602
+ const ancestorsOf = (id) => {
7603
+ const held = ancestors.get(id);
7604
+ if (held !== undefined)
7605
+ return held;
7606
+ const n = byId.get(id);
7607
+ if (n === undefined)
7608
+ return;
7609
+ const parents = graph();
7603
7610
  const out = new Set;
7604
7611
  const todo = [n];
7605
7612
  const own = countryOnMap(n);
@@ -7617,26 +7624,56 @@ function createPlaceReader2(options = {}) {
7617
7624
  todo.push(parent);
7618
7625
  }
7619
7626
  }
7620
- ancestorsOf.set(n.id, out);
7621
- }
7622
- const phrases = [...byPrint.keys()].filter((k) => k.includes(" ")).sort((a, b) => b.length - a.length);
7623
- const printsSorted = [...byPrint.keys()].map((k, i) => [k, i]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
7627
+ ancestors.set(id, out);
7628
+ return out;
7629
+ };
7630
+ let byStem;
7631
+ let byGeneric;
7624
7632
  return {
7625
7633
  byId,
7626
7634
  byPrint,
7627
- printsSorted,
7635
+ get byStem() {
7636
+ if (byStem !== undefined)
7637
+ return byStem;
7638
+ byStem = new Map;
7639
+ for (const k of byPrint.keys()) {
7640
+ if (k.length < MIN_STEM)
7641
+ continue;
7642
+ const stem = k.slice(0, MIN_STEM);
7643
+ const run = byStem.get(stem);
7644
+ if (run === undefined)
7645
+ byStem.set(stem, [k]);
7646
+ else
7647
+ run.push(k);
7648
+ }
7649
+ return byStem;
7650
+ },
7628
7651
  byCode,
7629
7652
  byTruncation,
7630
7653
  byCountryCode,
7631
7654
  bySubdivisionPart,
7632
7655
  byOireachtas,
7633
7656
  ancestorsOf,
7634
- carries,
7635
- phrases,
7657
+ get carries() {
7658
+ graph();
7659
+ return carries;
7660
+ },
7636
7661
  listedPhrases,
7637
7662
  byHeading,
7638
7663
  byRunPrint,
7639
- byGeneric
7664
+ get byGeneric() {
7665
+ if (byGeneric !== undefined)
7666
+ return byGeneric;
7667
+ byGeneric = new Map;
7668
+ for (const n of source)
7669
+ if (n.kind === "city")
7670
+ for (const p of [n.name, ...n.prints]) {
7671
+ const k = genericKey2(fold(p));
7672
+ if (k !== undefined)
7673
+ push(byGeneric, k, n);
7674
+ }
7675
+ return byGeneric;
7676
+ }
7640
7677
  };
7641
7678
  }
7642
7679
  function idx() {
@@ -7647,7 +7684,7 @@ function createPlaceReader2(options = {}) {
7647
7684
  return index;
7648
7685
  }
7649
7686
  function ancestorIds(n) {
7650
- return idx().ancestorsOf.get(n.id) ?? new Set;
7687
+ return idx().ancestorsOf(n.id) ?? new Set;
7651
7688
  }
7652
7689
  function isAncestor(a, b) {
7653
7690
  return a.id === b.id || ancestorIds(b).has(a.id);
@@ -7892,27 +7929,9 @@ function createPlaceReader2(options = {}) {
7892
7929
  if (folded.length < MIN_STEM)
7893
7930
  return [];
7894
7931
  const i = idx();
7895
- const sorted = i.printsSorted;
7896
- let lo = 0;
7897
- let hi = sorted.length;
7898
- while (lo < hi) {
7899
- const mid = lo + hi >>> 1;
7900
- if (sorted[mid][0] < folded)
7901
- lo = mid + 1;
7902
- else
7903
- hi = mid;
7904
- }
7905
- const run = [];
7906
- for (let k = lo;k < sorted.length; k++) {
7907
- const at = sorted[k];
7908
- if (!at[0].startsWith(folded))
7909
- break;
7910
- run.push(at);
7911
- }
7912
- run.sort((a, b) => a[1] - b[1]);
7913
7932
  const out = [];
7914
- for (const [key] of run) {
7915
- if (key.length <= folded.length)
7933
+ for (const key of i.byStem.get(folded.slice(0, MIN_STEM)) ?? []) {
7934
+ if (key.length <= folded.length || !key.startsWith(folded))
7916
7935
  continue;
7917
7936
  if (key[folded.length] === " ")
7918
7937
  continue;
package/dist/geocode.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  place2,
6
6
  placeFromId2,
7
7
  placeParts2
8
- } from "./chunks/place-zd6bq670.js";
8
+ } from "./chunks/place-5kmn6jgj.js";
9
9
 
10
10
  var PLACE_TOWNS = {
11
11
  "AUS-ACT": "Acton~~r3dp~9973368|Ainslie~~r3dp~8348552|Amaroo~~r3dp~8349331|Aranda~~r3dp~8349333|Banks~~r3dn~8348388|Barton~~r3dp~8349163|Belconnen~~r3dp~2176373|Bonner~~r3dp~9973375|Bonython~~r3dn~8349164|Braddon~~r3dp~8349165|Bruce~~r3dp~8349301|Calwell~~r3dn~8347865|Campbell~~r3dp~2172618|Canberra City~~r3dp~8347868|Casey~~r3dp~8349161~AU.07.21610|Chapman~~r39y~8349166|Charnwood~~r39z~8349169|Chifley~~r3dn~8348372|Chisholm~~r3dn~8349303|Conder~~r3dn~8349167|Cook~~r3dp~8347746~AU.04.32500|Coombs~~r39z~9973426|Crace~~r3dp~8349353|Curtin~~r3dp~8349171|Deakin~~r3dp~8349172|Dickson~~r3dp~8348400|Downer~~r3dp~8348308|Duffy~~r39y~8349425|Dunlop~~r39z~8349173|Evatt~~r3dp~8349175|Fadden~~r3dn~8348126|Farrer~~r3dn~8347869|Fisher~~r39y~8349304~CA.03.5953379|Florey~~r39z~8349174|Flynn~~r39z~8349305|Forde~~r3dp~8347874|Forrest~~r3dp~8504554|Franklin~~r3dp~8349306|Fraser~~r39z~8348647|Garran~~r3dn~9973428|Gilmore~~r3dn~8349400|Giralang~~r3dp~8348680|Gordon~~r3dn~8348660|Gowrie~~r3dn~8348892|Greenway~~r3dn~8349176|Griffith~~r3dp~8349307~AU.02.13450|Gungahlin~~r3dp~8349178|Hackett~~r3dp~8349180|Harrison~~r3dp~8349179|Hawker~~r39z~8349385|Higgins~~r39z~8349181|Holder~~r39y~8349308|Holt~~r39z~8347705|Hughes~~r3dn~8349446|Isaacs~~r3dn~8349182|Isabella Plains~~r3dn~8349183|Jacka~~r3dp~9973376|Jervis Bay Village~~r3g0~2162322|Kaleen~~r3dp~6619483|Kambah~~r39y~8348370|Kingston~~r3dp~8349299~~3489854|Latham~~r39z~8349309|Lyneham~~r3dp~8347876|Lyons~~r3dn~8349159|Macarthur~~r3dn~7302189|Macgregor~~r39z~8348907|Macquarie~~r3dp~7281844|Mawson~~r3dn~8348684|McKellar~~r3dp~8349184|Melba~~r39z~8349186|Monash~~r3dn~8349310~AU.07.24970|Narrabundah~~r3dn~8349435|Ngunnawal~~r3dp~8349187|Nicholls~~r3dp~8349185|O'Connor~~r3dp~8348190|O'Malley~~r3dn~8349436|Oxley~~r3dn~8349413|Page~~r39z~8348129|Palmerston~~r3dp~8349170~AU.03.72800|Pearce~~r3dn~8349379|Phillip~~r3dn~2153335|Red Hill~~r3dp~9973374|Reid~~r3dp~8348371|Richardson~~r3dn~8349188|Rivett~~r39y~8349189|Scullin~~r39z~8349327|Spence~~r3dp~8349313|Stirling~~r39y~8349380~AU.08.57910,CA.01.4802009,GB.SCT.W6|Symonston~~r3dn~8349190|Theodore~~r3dn~8348420~CA.11.4709028|Torrens~~r3dn~8348973|Tuggeranong~~r3dn~2145936|Turner~~r3dp~8348040|Wanniassa~~r3dn~8349191|Waramanga~~r39y~8349192|Watson~~r3dp~8348373~CA.11.4710062|Weetangera~~r39z~2144224|Weston~~r39y~8349397|Wright~~r39z~9973427|Yarralumla~~r3dp~8348374",
@@ -149,7 +149,8 @@ var PLACE_TOWNS = {
149
149
  "USA-WY": "Afton~~9x95~5816861|Alpine~~9x9j~5817073~AU.07.20110|Antelope Valley-Crestview~~9xug~7260797|Arapahoe~~9xdu~5817340|Bar Nunn~~9xsk~5817809|Basin~~9xgh~5817923|Bear River~~9x35~5818158|Big Piney~~9x99~5818702|Buffalo~~9xuh~5819881|Byron~~9xfy~5820291~AU.02.11350|Casper~~9xs7~5820705|Cheyenne~~9xm6~5821086|Clearview Acres~~9x6k~5821415|Cody~~9xfm~5821593|Cokeville~~9x3p~5821618|Cowley~~9xfz~5822154~CA.01.4803016|Dayton~~9xgx~5822752|Diamondville~~9x3m~5823199|Douglas~~9xt5~5823516~AU.04.32810~3042237|Dubois~~9xdp~5823819|Ethete~~9xds~5824773|Evanston~~9x34~5824805|Evansville~~9xs7~5824810|Fort Washakie~~9xds~5825424|Fox Farm-College~~9xm3~7261302|Gillette~~9xug~5826027|Glenrock~~9xse~5826088|Green River~~9x6h~5826559|Greybull~~9xgj~5826603|Guernsey~~9xt8~5826723|Hanna~~9xkn~5826986~CA.01.4804011|Hartrandt~~9xs7~5827151|Hoback~~9x9n~5827703|Jackson~~9x9p~5828648|James Town~~9x6h~5828717|Kemmerer~~9x3m~5829425|La Barge~~9x98~5829816|Lander~~9xde~5830007|Laramie~~9xkg~5830062|Lovell~~9xfz~5831176|Lucerne~~9xg0~5831275|Lusk~~9xte~5831333|Lyman~~9x3e~5831346|Marbleton~~9x9d~5831530|Mills~~9xs7~5832481|Moorcroft~~9xv7~5832698|Moose Wilson Road~~9x9p~5832759|Mountain View~~9x3d~5832901|Newcastle~~9xvc~5833349~AU.02.15900|North Rock Springs~~9x6k~5833892|Pine Bluffs~~9xmf~5835069|Pine Haven~~9xvk~5835124|Pinedale~~9x9g~5835178|Powell~~9xfw~5835606|Purple Sage~~9x6k~5835760|Rafter J Ranch~~9x9p~5835865|Ranchester~~9xgz~5835955|Ranchettes~~9xm6~5835956|Rawlins~~9x7t~5836068|Reliance~~9x6m~5836399|Riverton~~9xdu~5836665|Rock Springs~~9x6k~5836898|Saratoga~~9xk5~5837593|Sheridan~~9xgy~5838198|Shoshoni~~9xej~5838312|Sleepy Hollow~~9xv5~5838617|South Greeley~~9xm3~5839233|South Park~~9x9p~5839264|Star Valley Ranch~~9x9h~8479282|Story~~9xgv~5840065|Sundance~~9xvu~5840284|Thermopolis~~9xg0~5840846|Torrington~~9xmz~5841207|Upton~~9xvd~5841818|Vista West~~9xs7~7176041|Washakie Ten~~9xg6~5842272|Wheatland~~9xmr~5842753|Wilson~~9x9p~5843239|Worland~~9xg4~5843495|Wright~~9xub~5843515"
150
150
  };
151
151
 
152
- var slug = (s) => s.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
152
+ var ASCII = /^[ -~]*$/;
153
+ var slug = (s) => (ASCII.test(s) ? s : s.normalize("NFD").replace(/\p{M}/gu, "")).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
153
154
  var towns;
154
155
  function geocodeTowns() {
155
156
  if (towns !== undefined)
@@ -182,6 +183,8 @@ function townNodes() {
182
183
  const ascii = new Map;
183
184
  for (const parent of Object.keys(PLACE_TOWNS))
184
185
  for (const row of PLACE_TOWNS[parent].split("|")) {
186
+ if (row[row.indexOf("~") + 1] === "~")
187
+ continue;
185
188
  const [, a, , id] = row.split("~");
186
189
  if (a !== "")
187
190
  ascii.set(id, a);
package/dist/place.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  placesRelation2,
20
20
  probablySamePlace2,
21
21
  sameReading2
22
- } from "./chunks/place-zd6bq670.js";
22
+ } from "./chunks/place-5kmn6jgj.js";
23
23
  import"./chunks/place-tcgfvemw.js";
24
24
  export {
25
25
  DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
package/dist/school.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  areAllPlaceTokens2,
13
13
  placeRelation2,
14
14
  sameReading2
15
- } from "./chunks/place-zd6bq670.js";
15
+ } from "./chunks/place-5kmn6jgj.js";
16
16
  import {
17
17
  validity
18
18
  } from "./chunks/place-q9kwsmzd.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finbheara/domain",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Places, CLRG regions, school names, ages, dances, competition titles and schedules, and a person's print in its role, as they are printed: read, compared and told apart",
5
5
  "keywords": [
6
6
  "places",