@finbheara/domain 0.34.0 → 0.36.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/README.md CHANGED
@@ -133,15 +133,21 @@ geocode("Prague", { near: "RCCEA", declared: true }).isPlace();
133
133
  // no namesake town is read
134
134
  geocode("Fife").isPlace(); // false: a town of Washington, and a council area
135
135
  // of Scotland
136
+ geocode("Prague").isPlace(); // false: a town of Oklahoma, and the capital of
137
+ // Czechia
138
+ geocode("Prague, Oklahoma").pl3; // "USA-OK/prague"
136
139
  ```
137
140
 
138
141
  The layer reads a bare town by its name alone, so it reads one only where nothing contradicts
139
142
  it. A context (a `country` or `near`, read by the store, never as a town of the layer) that
140
143
  reads to ONE place which neither holds the town nor shares its country stops the layer: `Prague`
141
144
  near `RCCEA` and `Whitecross` under `Ireland` and `Ulster` read nothing. A context the store
142
- reads nothing for, or reads as several places, stops nothing, so with no context
143
- `geocode("Prague")` is still Prague, Oklahoma. A town named like a GeoNames admin2 area of those
144
- six countries that does not hold it (`Fife`) reads only where a context places it. A print with a
145
+ reads nothing for, or reads as several places, stops nothing. A town named like a GeoNames admin2
146
+ area of those six countries that does not hold it (`Fife`) reads only where a qualifier or a
147
+ context places it. So does a town named like a capital or a major city elsewhere (a `cities500`
148
+ place outside the six countries that is a capital or holds a million people, and is more populous
149
+ than the town): bare `Prague` and `Copenhagen` read nothing, where they would read the towns of
150
+ Oklahoma and New York, and `Prague` in a USA context is the Oklahoma town. A print with a
145
151
  qualifier (`Yonkers, NY`) is never stopped: the context never overrules the print.
146
152
 
147
153
  A `Place` is one of four arms: `resolved`, `plural` (a print naming more than one place),
package/dist/age.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ printsUnderOpen2,
2
3
  TITLE_RANGE_MIN2,
3
4
  TITLE_RANGE_MAX2,
4
5
  ageTitleToken2,
@@ -12,6 +13,7 @@ import {
12
13
  MIN_MAJOR_AGE2,
13
14
  MIN_FEIS_AGE2,
14
15
  YOUNGEST_BAND_TOP2,
16
+ OLDEST_BAND_FLOOR2,
15
17
  YOB_RANGE2,
16
18
  DANCE_UP_YEARS2,
17
19
  ageOnJanuary12,
@@ -35,7 +37,7 @@ import {
35
37
  youngFloor2,
36
38
  tooYoungForMajor2,
37
39
  tooYoungForFeis2
38
- } from "./chunks/place-8k74cr5j.js";
40
+ } from "./chunks/place-3w1mr2vh.js";
39
41
  export {
40
42
  ADULT_FLOOR2 as ADULT_FLOOR,
41
43
  AVERAGE_AGE_DECIMALS2 as AVERAGE_AGE_DECIMALS,
@@ -45,6 +47,7 @@ export {
45
47
  MAJORS_FLOOR_YEARS2 as MAJORS_FLOOR_YEARS,
46
48
  MIN_FEIS_AGE2 as MIN_FEIS_AGE,
47
49
  MIN_MAJOR_AGE2 as MIN_MAJOR_AGE,
50
+ OLDEST_BAND_FLOOR2 as OLDEST_BAND_FLOOR,
48
51
  TITLE_RANGE_MAX2 as TITLE_RANGE_MAX,
49
52
  TITLE_RANGE_MIN2 as TITLE_RANGE_MIN,
50
53
  UNDER_CAP2 as UNDER_CAP,
@@ -64,6 +67,7 @@ export {
64
67
  canOverlap2 as canOverlap,
65
68
  intersectBirthYears2 as intersectBirthYears,
66
69
  isAveraged2 as isAveraged,
70
+ printsUnderOpen2 as printsUnderOpen,
67
71
  roundedMeanHundredths2 as roundedMeanHundredths,
68
72
  tooYoungForFeis2 as tooYoungForFeis,
69
73
  tooYoungForMajor2 as tooYoungForMajor,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Age2,
3
3
  ageRelation2
4
- } from "./place-8k74cr5j.js";
4
+ } from "./place-3w1mr2vh.js";
5
5
  import {
6
6
  validity
7
7
  } from "./place-q9kwsmzd.js";
@@ -13,6 +13,8 @@ var UNDER = new RegExp(String.raw`${UNDER_WORD}(\d{1,2})(?![0-9])(?![a-z][a-z0-9
13
13
  var JOINED_CAPS = new RegExp(String.raw`${UNDER_WORD}\d{1,2}(?![0-9])(?:(?:\s*(?:&|,|\/|\band\b)\s*(?:${UNDER_WORD})?|\s+${UNDER_WORD})\d{1,2}(?![0-9]))+`, "i");
14
14
  var JOINED_NOT = /^(?:\s*(?:yrs?|years?|-?\s*hand)\b|[a-z])/i;
15
15
  var JOINED_OPEN = /^(?:\s*\+|\s*(?:&|and)\s*(?:o|over|older|up)\b)/i;
16
+ var UNDER_OPEN = new RegExp(String.raw`${UNDER_WORD}\d{1,2}(?![0-9])\s*(?:&|\band\b)\s*(?:o|over|older|up)\b`, "i");
17
+ var printsUnderOpen2 = (print) => UNDER_OPEN.test(print);
16
18
  var UNDER_STRIDE = /^\s*\/\s*0*([1-9]\d?)\s*yrs?(?![a-z0-9])/i;
17
19
  var AND_UNDER = /(?<![a-z0-9])(\d{1,2})\s*(?:years?\s*)?(?:&|\/|\band\b)\s*u(?:nder)?(?![a-z])(?!\s*\d)/i;
18
20
  var AND_UNDER_RANGE = /(?<![a-z0-9])(\d{1,2})\s*(?:&|\band\b)\s*under\s*(\d{1,2})(?![a-z0-9])/i;
@@ -60,6 +62,8 @@ function readAnchored(title, s, offset, aside = false) {
60
62
  const joined = readJoined(title, s, offset);
61
63
  if (joined !== null)
62
64
  return joined;
65
+ if (UNDER_OPEN.test(s))
66
+ return NONE;
63
67
  for (const re of [AND_OVER, OVER_WORD, OVER_GLUED]) {
64
68
  const m = re.exec(s);
65
69
  if (m?.[1] !== undefined)
@@ -188,6 +192,7 @@ var YOUNG_FLOOR2 = Object.freeze({ hard: 2, soft: 4 });
188
192
  var MIN_MAJOR_AGE2 = 4;
189
193
  var MIN_FEIS_AGE2 = 3;
190
194
  var YOUNGEST_BAND_TOP2 = MAJORS_FLOOR_YEARS2;
195
+ var OLDEST_BAND_FLOOR2 = 100;
191
196
  var YOB_RANGE2 = Object.freeze({ first: 1901, last: 2099 });
192
197
  var DANCE_UP_YEARS2 = 1;
193
198
  var ageOnJanuary12 = (year, born) => year - born - 1;
@@ -347,6 +352,11 @@ function refuseBelowYoungest(r) {
347
352
  return r;
348
353
  return { ...r, interval: null, refusal: "below-youngest-band", clauses: [] };
349
354
  }
355
+ function refuseAboveOldest(r) {
356
+ if (r.interval === null || r.interval.lo < OLDEST_BAND_FLOOR2)
357
+ return r;
358
+ return { ...r, interval: null, refusal: "above-oldest-band", clauses: [] };
359
+ }
350
360
 
351
361
  class AgeMisuseError2 extends Error {
352
362
  misuse;
@@ -377,7 +387,7 @@ function fromPrint(print, context = {}) {
377
387
  const ladder = context.ladder ?? NO_LADDER;
378
388
  const year = context.year === undefined ? currentYear() : context.year;
379
389
  const ag1 = print.trim().toLowerCase();
380
- const reading = ag1 === "" ? { kind: null, interval: null, refusal: null, clauses: [], parts: [] } : refuseBelowYoungest(read(print.trim(), ladder, context.top === true));
390
+ const reading = ag1 === "" ? { kind: null, interval: null, refusal: null, clauses: [], parts: [] } : refuseAboveOldest(refuseBelowYoungest(read(print.trim(), ladder, context.top === true)));
381
391
  const iv = reading.interval;
382
392
  const arm = ag1 === "" ? "empty" : iv === null ? "open" : "band";
383
393
  const ag2 = iv !== null ? display(iv) : ag1 === "" ? "" : `${ag1}?`;
@@ -652,4 +662,4 @@ function youngFloor2(year, oldest) {
652
662
  var tooYoungForMajor2 = (year, oldest) => yearsSinceBirth2(year, oldest) < MIN_MAJOR_AGE2;
653
663
  var tooYoungForFeis2 = (year, oldest) => yearsSinceBirth2(year, oldest) < MIN_FEIS_AGE2;
654
664
 
655
- export { TITLE_RANGE_MIN2, TITLE_RANGE_MAX2, ageTitleToken2, adultBeside2, YOUNGEST_FLOOR2, ADULT_FLOOR2, MAJORS_FLOOR_YEARS2, UNDER_CAP2, UNDER_CAP_MAX_TOP2, YOUNG_FLOOR2, MIN_MAJOR_AGE2, MIN_FEIS_AGE2, YOUNGEST_BAND_TOP2, YOB_RANGE2, DANCE_UP_YEARS2, ageOnJanuary12, yearsSinceBirth2, AgeMisuseError2, Age2, birthYearsOfInterval2, ageRelation2, canOverlap2, AVERAGE_AGE_DECIMALS2, roundedMeanHundredths2, isAveraged2, averageAge2, birthYearsDisjoint2, intersectBirthYears2, birthYearsMeet2, underCapApplies2, underCappedYears2, underCapRefuses2, validYOB2, youngFloor2, tooYoungForMajor2, tooYoungForFeis2 };
665
+ export { printsUnderOpen2, TITLE_RANGE_MIN2, TITLE_RANGE_MAX2, ageTitleToken2, adultBeside2, YOUNGEST_FLOOR2, ADULT_FLOOR2, MAJORS_FLOOR_YEARS2, UNDER_CAP2, UNDER_CAP_MAX_TOP2, YOUNG_FLOOR2, MIN_MAJOR_AGE2, MIN_FEIS_AGE2, YOUNGEST_BAND_TOP2, OLDEST_BAND_FLOOR2, YOB_RANGE2, DANCE_UP_YEARS2, ageOnJanuary12, yearsSinceBirth2, AgeMisuseError2, Age2, birthYearsOfInterval2, ageRelation2, canOverlap2, AVERAGE_AGE_DECIMALS2, roundedMeanHundredths2, isAveraged2, averageAge2, birthYearsDisjoint2, intersectBirthYears2, birthYearsMeet2, underCapApplies2, underCappedYears2, underCapRefuses2, validYOB2, youngFloor2, tooYoungForMajor2, tooYoungForFeis2 };