@pubid/pubid 0.1.75 → 0.1.77

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.
@@ -21,7 +21,7 @@
21
21
  //!
22
22
  //! The wave-2 substrate flavors (pubid/pubid-grammar#158) — api,
23
23
  //! ashrae, asme, astm, cie, csa, gost, iala, like evs before them —
24
- //! register the pure-TS worker engine as their substrate runtime:
24
+ //! use the pure-TS worker engine:
25
25
  //! node-only modules never enter this graph. Waves 5 batch 1-3
26
26
  //! (omg/w3c/tgpp, sae/jcgm/oasis/xsf, then easc/ecma/gb/iana/ietf/ogc)
27
27
  //! and the wave 5 final batch (calconnect/iho/plateau) ride the same
@@ -134,6 +134,7 @@ import { makeW3cGrammarImplementation } from "./w3c/implementation.js";
134
134
  import * as tgppSubstrate from "./tgpp/generated/substrate.js";
135
135
  import { tgppWorkerRuntime } from "./tgpp/grammar.worker.js";
136
136
  import { makeTgppGrammarImplementation } from "./tgpp/implementation.js";
137
+ import { lazyRuntime, parseBoundWith } from "../parg/bound.js";
137
138
  /** The worker-available flavor implementations, wired to each other:
138
139
  * every member's foreign lookups run over this same set (so bsi's
139
140
  * adopted ISO routing, cen_cenelec's implicit IEC adoption and gost's
@@ -146,143 +147,143 @@ export function workerForeignResolver() {
146
147
  const map = {
147
148
  oiml: oimlWorkerGrammarImplementation(),
148
149
  xsf: (() => {
149
- xsfSubstrate.registerRuntime(xsfWorkerRuntime);
150
- return makeXsfGrammarImplementation((body) => xsfSubstrate.boundToWire(xsfSubstrate.parseBound(body)));
150
+ const runtime = lazyRuntime(xsfWorkerRuntime);
151
+ return makeXsfGrammarImplementation((body) => xsfSubstrate.boundToWire(parseBoundWith(runtime, xsfSubstrate.FLAVOR, body)));
151
152
  })(),
152
153
  doi: doiGrammarImplementation(),
153
154
  iana: (() => {
154
- ianaSubstrate.registerRuntime(ianaWorkerRuntime);
155
- return makeIanaGrammarImplementation((body) => ianaSubstrate.boundToWire(ianaSubstrate.parseBound(body)));
155
+ const runtime = lazyRuntime(ianaWorkerRuntime);
156
+ return makeIanaGrammarImplementation((body) => ianaSubstrate.boundToWire(parseBoundWith(runtime, ianaSubstrate.FLAVOR, body)));
156
157
  })(),
157
158
  un: unGrammarImplementation(),
158
159
  plateau: (() => {
159
- plateauSubstrate.registerRuntime(plateauWorkerRuntime);
160
- return makePlateauGrammarImplementation((body) => plateauSubstrate.boundToWire(plateauSubstrate.parseBound(body)));
160
+ const runtime = lazyRuntime(plateauWorkerRuntime);
161
+ return makePlateauGrammarImplementation((body) => plateauSubstrate.boundToWire(parseBoundWith(runtime, plateauSubstrate.FLAVOR, body)));
161
162
  })(),
162
163
  w3c: (() => {
163
- w3cSubstrate.registerRuntime(w3cWorkerRuntime);
164
- return makeW3cGrammarImplementation((body) => w3cSubstrate.boundToWire(w3cSubstrate.parseBound(body)));
164
+ const runtime = lazyRuntime(w3cWorkerRuntime);
165
+ return makeW3cGrammarImplementation((body) => w3cSubstrate.boundToWire(parseBoundWith(runtime, w3cSubstrate.FLAVOR, body)));
165
166
  })(),
166
167
  omg: (() => {
167
- omgSubstrate.registerRuntime(omgWorkerRuntime);
168
- return makeOmgGrammarImplementation((body) => omgSubstrate.boundToWire(omgSubstrate.parseBound(body)));
168
+ const runtime = lazyRuntime(omgWorkerRuntime);
169
+ return makeOmgGrammarImplementation((body) => omgSubstrate.boundToWire(parseBoundWith(runtime, omgSubstrate.FLAVOR, body)));
169
170
  })(),
170
171
  ogc: (() => {
171
- ogcSubstrate.registerRuntime(ogcWorkerRuntime);
172
- return makeOgcGrammarImplementation((body) => ogcSubstrate.boundToWire(ogcSubstrate.parseBound(body)));
172
+ const runtime = lazyRuntime(ogcWorkerRuntime);
173
+ return makeOgcGrammarImplementation((body) => ogcSubstrate.boundToWire(parseBoundWith(runtime, ogcSubstrate.FLAVOR, body)));
173
174
  })(),
174
175
  isbn: isbnGrammarImplementation(),
175
176
  easc: (() => {
176
- eascSubstrate.registerRuntime(eascWorkerRuntime);
177
- return makeEascGrammarImplementation((body) => eascSubstrate.boundToWire(eascSubstrate.parseBound(body)));
177
+ const runtime = lazyRuntime(eascWorkerRuntime);
178
+ return makeEascGrammarImplementation((body) => eascSubstrate.boundToWire(parseBoundWith(runtime, eascSubstrate.FLAVOR, body)));
178
179
  })(),
179
180
  ecma: (() => {
180
- ecmaSubstrate.registerRuntime(ecmaWorkerRuntime);
181
- return makeEcmaGrammarImplementation((body) => ecmaSubstrate.boundToWire(ecmaSubstrate.parseBound(body)));
181
+ const runtime = lazyRuntime(ecmaWorkerRuntime);
182
+ return makeEcmaGrammarImplementation((body) => ecmaSubstrate.boundToWire(parseBoundWith(runtime, ecmaSubstrate.FLAVOR, body)));
182
183
  })(),
183
184
  tgpp: (() => {
184
- tgppSubstrate.registerRuntime(tgppWorkerRuntime);
185
- return makeTgppGrammarImplementation((body) => tgppSubstrate.boundToWire(tgppSubstrate.parseBound(body)));
185
+ const runtime = lazyRuntime(tgppWorkerRuntime);
186
+ return makeTgppGrammarImplementation((body) => tgppSubstrate.boundToWire(parseBoundWith(runtime, tgppSubstrate.FLAVOR, body)));
186
187
  })(),
187
188
  oasis: (() => {
188
- oasisSubstrate.registerRuntime(oasisWorkerRuntime);
189
- return makeOasisGrammarImplementation((body) => oasisSubstrate.boundToWire(oasisSubstrate.parseBound(body)));
189
+ const runtime = lazyRuntime(oasisWorkerRuntime);
190
+ return makeOasisGrammarImplementation((body) => oasisSubstrate.boundToWire(parseBoundWith(runtime, oasisSubstrate.FLAVOR, body)));
190
191
  })(),
191
192
  iho: (() => {
192
- ihoSubstrate.registerRuntime(ihoWorkerRuntime);
193
- return makeIhoGrammarImplementation((body) => ihoSubstrate.boundToWire(ihoSubstrate.parseBound(body)));
193
+ const runtime = lazyRuntime(ihoWorkerRuntime);
194
+ return makeIhoGrammarImplementation((body) => ihoSubstrate.boundToWire(parseBoundWith(runtime, ihoSubstrate.FLAVOR, body)));
194
195
  })(),
195
196
  calconnect: (() => {
196
- calconnectSubstrate.registerRuntime(calconnectWorkerRuntime);
197
- return makeCalconnectGrammarImplementation((body) => calconnectSubstrate.boundToWire(calconnectSubstrate.parseBound(body)));
197
+ const runtime = lazyRuntime(calconnectWorkerRuntime);
198
+ return makeCalconnectGrammarImplementation((body) => calconnectSubstrate.boundToWire(parseBoundWith(runtime, calconnectSubstrate.FLAVOR, body)));
198
199
  })(),
199
200
  gb: (() => {
200
- gbSubstrate.registerRuntime(gbWorkerRuntime);
201
- return makeGbGrammarImplementation((body) => gbSubstrate.boundToWire(gbSubstrate.parseBound(body)));
201
+ const runtime = lazyRuntime(gbWorkerRuntime);
202
+ return makeGbGrammarImplementation((body) => gbSubstrate.boundToWire(parseBoundWith(runtime, gbSubstrate.FLAVOR, body)));
202
203
  })(),
203
204
  jcgm: (() => {
204
- jcgmSubstrate.registerRuntime(jcgmWorkerRuntime);
205
- return makeJcgmGrammarImplementation((body) => jcgmSubstrate.boundToWire(jcgmSubstrate.parseBound(body)));
205
+ const runtime = lazyRuntime(jcgmWorkerRuntime);
206
+ return makeJcgmGrammarImplementation((body) => jcgmSubstrate.boundToWire(parseBoundWith(runtime, jcgmSubstrate.FLAVOR, body)));
206
207
  })(),
207
208
  sae: (() => {
208
- saeSubstrate.registerRuntime(saeWorkerRuntime);
209
- return makeSaeGrammarImplementation((body) => saeSubstrate.boundToWire(saeSubstrate.parseBound(body)));
209
+ const runtime = lazyRuntime(saeWorkerRuntime);
210
+ return makeSaeGrammarImplementation((body) => saeSubstrate.boundToWire(parseBoundWith(runtime, saeSubstrate.FLAVOR, body)));
210
211
  })(),
211
212
  etsi: (() => {
212
- etsiSubstrate.registerRuntime(etsiWorkerRuntime);
213
- return makeEtsiGrammarImplementation((body) => etsiSubstrate.boundToWire(etsiSubstrate.parseBound(body)));
213
+ const runtime = lazyRuntime(etsiWorkerRuntime);
214
+ return makeEtsiGrammarImplementation((body) => etsiSubstrate.boundToWire(parseBoundWith(runtime, etsiSubstrate.FLAVOR, body)));
214
215
  })(),
215
216
  jis: (() => {
216
- jisSubstrate.registerRuntime(jisWorkerRuntime);
217
- return makeJisGrammarImplementation((body) => jisSubstrate.boundToWire(jisSubstrate.parseBound(body)));
217
+ const runtime = lazyRuntime(jisWorkerRuntime);
218
+ return makeJisGrammarImplementation((body) => jisSubstrate.boundToWire(parseBoundWith(runtime, jisSubstrate.FLAVOR, body)));
218
219
  })(),
219
220
  iec: (() => {
220
- iecSubstrate.registerRuntime(iecWorkerRuntime);
221
- return makeIecGrammarImplementation((body) => iecSubstrate.boundToWire(iecSubstrate.parseBound(body)));
221
+ const runtime = lazyRuntime(iecWorkerRuntime);
222
+ return makeIecGrammarImplementation((body) => iecSubstrate.boundToWire(parseBoundWith(runtime, iecSubstrate.FLAVOR, body)));
222
223
  })(),
223
224
  cie: (() => {
224
- cieSubstrate.registerRuntime(cieWorkerRuntime);
225
- return makeCieGrammarImplementation((body) => cieSubstrate.boundToWire(cieSubstrate.parseBound(body)));
225
+ const runtime = lazyRuntime(cieWorkerRuntime);
226
+ return makeCieGrammarImplementation((body) => cieSubstrate.boundToWire(parseBoundWith(runtime, cieSubstrate.FLAVOR, body)));
226
227
  })(),
227
228
  bipm: (() => {
228
- bipmSubstrate.registerRuntime(bipmWorkerRuntime);
229
- return makeBipmGrammarImplementation((body) => bipmSubstrate.boundToWire(bipmSubstrate.parseBound(body)));
229
+ const runtime = lazyRuntime(bipmWorkerRuntime);
230
+ return makeBipmGrammarImplementation((body) => bipmSubstrate.boundToWire(parseBoundWith(runtime, bipmSubstrate.FLAVOR, body)));
230
231
  })(),
231
232
  iso: isoWorkerGrammarImplementation(),
232
233
  cen_cenelec: (() => {
233
- cenSubstrate.registerRuntime(cenCenelecWorkerRuntime);
234
- return makeCenCenelecGrammarImplementation((body) => cenSubstrate.boundToWire(cenSubstrate.parseBound(body)), resolve);
234
+ const runtime = lazyRuntime(cenCenelecWorkerRuntime);
235
+ return makeCenCenelecGrammarImplementation((body) => cenSubstrate.boundToWire(parseBoundWith(runtime, cenSubstrate.FLAVOR, body)), resolve);
235
236
  })(),
236
237
  astm: (() => {
237
- astmSubstrate.registerRuntime(astmWorkerRuntime);
238
- return makeAstmGrammarImplementation((body) => astmSubstrate.boundToWire(astmSubstrate.parseBound(body)));
238
+ const runtime = lazyRuntime(astmWorkerRuntime);
239
+ return makeAstmGrammarImplementation((body) => astmSubstrate.boundToWire(parseBoundWith(runtime, astmSubstrate.FLAVOR, body)));
239
240
  })(),
240
241
  idf: (() => {
241
- idfSubstrate.registerRuntime(idfWorkerRuntime);
242
- return makeIdfGrammarImplementation((body) => idfSubstrate.boundToWire(idfSubstrate.parseBound(body)));
242
+ const runtime = lazyRuntime(idfWorkerRuntime);
243
+ return makeIdfGrammarImplementation((body) => idfSubstrate.boundToWire(parseBoundWith(runtime, idfSubstrate.FLAVOR, body)));
243
244
  })(),
244
245
  gost: (() => {
245
- gostSubstrate.registerRuntime(gostWorkerRuntime);
246
- return makeGostGrammarImplementation((body) => gostSubstrate.boundToWire(gostSubstrate.parseBound(body)), resolve);
246
+ const runtime = lazyRuntime(gostWorkerRuntime);
247
+ return makeGostGrammarImplementation((body) => gostSubstrate.boundToWire(parseBoundWith(runtime, gostSubstrate.FLAVOR, body)), resolve);
247
248
  })(),
248
249
  evs: (() => {
249
250
  // The substrate with the pure-TS worker engine (node-only modules
250
251
  // never enter this graph); the delta is the shared implementation.
251
- evsSubstrate.registerRuntime(evsWorkerRuntime);
252
- return makeEvsGrammarImplementation((body) => evsSubstrate.boundToWire(evsSubstrate.parseBound(body)), resolve);
252
+ const runtime = lazyRuntime(evsWorkerRuntime);
253
+ return makeEvsGrammarImplementation((body) => evsSubstrate.boundToWire(parseBoundWith(runtime, evsSubstrate.FLAVOR, body)), resolve);
253
254
  })(),
254
255
  ashrae: (() => {
255
- ashraeSubstrate.registerRuntime(ashraeWorkerRuntime);
256
- return makeAshraeGrammarImplementation((body) => ashraeSubstrate.boundToWire(ashraeSubstrate.parseBound(body)));
256
+ const runtime = lazyRuntime(ashraeWorkerRuntime);
257
+ return makeAshraeGrammarImplementation((body) => ashraeSubstrate.boundToWire(parseBoundWith(runtime, ashraeSubstrate.FLAVOR, body)));
257
258
  })(),
258
259
  bsi: (() => {
259
- bsiSubstrate.registerRuntime(bsiWorkerRuntime);
260
- return makeBsiGrammarImplementation((body) => bsiSubstrate.boundToWire(bsiSubstrate.parseBound(body)), resolve);
260
+ const runtime = lazyRuntime(bsiWorkerRuntime);
261
+ return makeBsiGrammarImplementation((body) => bsiSubstrate.boundToWire(parseBoundWith(runtime, bsiSubstrate.FLAVOR, body)), resolve);
261
262
  })(),
262
263
  csa: (() => {
263
- csaSubstrate.registerRuntime(csaWorkerRuntime);
264
- return makeCsaGrammarImplementation((body) => csaSubstrate.boundToWire(csaSubstrate.parseBound(body)), resolve);
264
+ const runtime = lazyRuntime(csaWorkerRuntime);
265
+ return makeCsaGrammarImplementation((body) => csaSubstrate.boundToWire(parseBoundWith(runtime, csaSubstrate.FLAVOR, body)), resolve);
265
266
  })(),
266
267
  asme: (() => {
267
- asmeSubstrate.registerRuntime(asmeWorkerRuntime);
268
- return makeAsmeGrammarImplementation((body) => asmeSubstrate.boundToWire(asmeSubstrate.parseBound(body)));
268
+ const runtime = lazyRuntime(asmeWorkerRuntime);
269
+ return makeAsmeGrammarImplementation((body) => asmeSubstrate.boundToWire(parseBoundWith(runtime, asmeSubstrate.FLAVOR, body)));
269
270
  })(),
270
271
  amca: amcaGrammarImplementation(),
271
272
  api: (() => {
272
- apiSubstrate.registerRuntime(apiWorkerRuntime);
273
- return makeApiGrammarImplementation((body) => apiSubstrate.boundToWire(apiSubstrate.parseBound(body)));
273
+ const runtime = lazyRuntime(apiWorkerRuntime);
274
+ return makeApiGrammarImplementation((body) => apiSubstrate.boundToWire(parseBoundWith(runtime, apiSubstrate.FLAVOR, body)));
274
275
  })(),
275
276
  itu: (() => {
276
- ituSubstrate.registerRuntime(ituWorkerRuntime);
277
- return makeItuGrammarImplementation((body) => ituSubstrate.boundToWire(ituSubstrate.parseBound(body)));
277
+ const runtime = lazyRuntime(ituWorkerRuntime);
278
+ return makeItuGrammarImplementation((body) => ituSubstrate.boundToWire(parseBoundWith(runtime, ituSubstrate.FLAVOR, body)));
278
279
  })(),
279
280
  ietf: (() => {
280
- ietfSubstrate.registerRuntime(ietfWorkerRuntime);
281
- return makeIetfGrammarImplementation((body) => ietfSubstrate.boundToWire(ietfSubstrate.parseBound(body)));
281
+ const runtime = lazyRuntime(ietfWorkerRuntime);
282
+ return makeIetfGrammarImplementation((body) => ietfSubstrate.boundToWire(parseBoundWith(runtime, ietfSubstrate.FLAVOR, body)));
282
283
  })(),
283
284
  iala: (() => {
284
- ialaSubstrate.registerRuntime(ialaWorkerRuntime);
285
- return makeIalaGrammarImplementation((body) => ialaSubstrate.boundToWire(ialaSubstrate.parseBound(body)));
285
+ const runtime = lazyRuntime(ialaWorkerRuntime);
286
+ return makeIalaGrammarImplementation((body) => ialaSubstrate.boundToWire(parseBoundWith(runtime, ialaSubstrate.FLAVOR, body)));
286
287
  })(),
287
288
  };
288
289
  return resolve;
@@ -6,7 +6,9 @@
6
6
  * the keys from any identifier that a worker flavor entry returns.
7
7
  *
8
8
  * `norm` uppercases the canonical render and deletes spaces; `undated`
9
- * strips every colon-year not followed by a dash; `all_parts`
9
+ * strips every delimited year (a colon-year or a parenthesized date) not
10
+ * followed by a dash, plus every dash-year that the parse marks as a
11
+ * year — never the digits of a document number; `all_parts`
10
12
  * additionally strips the parsed part (with its subpart) — structurally,
11
13
  * never by guessing: a trailing "-05" that pubid did not parse as a part
12
14
  * is a date day, not a part, and stays.
@@ -16,8 +18,10 @@
16
18
  export interface LaneKeys {
17
19
  /** The dated lane: the normalized canonical (uppercased, de-spaced). */
18
20
  dated: string;
19
- /** The undated lane: every colon-year not followed by a dash is gone
20
- * (base and supplement alike — one rule, no per-flavor casing). */
21
+ /** The undated lane: every colon-year and parenthesized date not
22
+ * followed by a dash is gone (base and supplement alike — one rule, no
23
+ * per-flavor casing), and so is every dash-year that the parse marks
24
+ * as a year. The digits of a document number always stay. */
21
25
  undated: string;
22
26
  /** The all-parts lane: the parsed part (and subpart) stripped from the
23
27
  * undated lane. Structural only — an unparsed trailing "-N" is never a
@@ -38,9 +42,12 @@ export interface LaneKeySource {
38
42
  */
39
43
  export declare function norm(canonical: string): string;
40
44
  /**
41
- * The undated lane from a norm key: every `:?`-year not followed by a
42
- * dash is stripped — globally, base and supplement years alike. Ruby's
43
- * `gsub(/:?(?:19|20)\d{2}(?=[^-]*$)/, "")` verbatim.
45
+ * The undated lane from a norm key: every delimited year not followed by
46
+ * a dash is stripped — globally, base and supplement years alike. A year
47
+ * is delimited when a colon introduces it (`:2015`) or when it is a whole
48
+ * parenthesized date (`(2001)`, `(10/2019)`, the reaffirmation
49
+ * `(R2020)`). No digit continues the year, and a bare digit run is never
50
+ * a year: `ISO19115`, `RFC2045` and `IEC62019` stay whole.
44
51
  */
45
52
  export declare function undatedNorm(normKey: string): string;
46
53
  /**
@@ -60,7 +67,8 @@ export declare function allPartsNorm(undated: string, part?: string, subpart?: s
60
67
  */
61
68
  export declare function structuralPart(components: Record<string, unknown>): string | undefined;
62
69
  /** The lane keys for an already-canonical record: norm from the render,
63
- * undated from the norm, all_parts from the parsed part and subpart. */
70
+ * undated from the norm and the parsed year, all_parts from the parsed
71
+ * part and subpart. */
64
72
  export declare function laneKeysFrom(canonical: string, components: Record<string, unknown>): LaneKeys;
65
73
  /** The lane keys of a parsed identifier: `laneKeysFrom(id.toHuman(),
66
74
  * id.toHash())`. Use it on the identifier that a worker flavor entry
package/dist/lane-keys.js CHANGED
@@ -6,7 +6,9 @@
6
6
  * the keys from any identifier that a worker flavor entry returns.
7
7
  *
8
8
  * `norm` uppercases the canonical render and deletes spaces; `undated`
9
- * strips every colon-year not followed by a dash; `all_parts`
9
+ * strips every delimited year (a colon-year or a parenthesized date) not
10
+ * followed by a dash, plus every dash-year that the parse marks as a
11
+ * year — never the digits of a document number; `all_parts`
10
12
  * additionally strips the parsed part (with its subpart) — structurally,
11
13
  * never by guessing: a trailing "-05" that pubid did not parse as a part
12
14
  * is a date day, not a part, and stays.
@@ -23,13 +25,43 @@ function escapeRegExp(text) {
23
25
  export function norm(canonical) {
24
26
  return canonical.toUpperCase().replaceAll(" ", "");
25
27
  }
28
+ const DELIMITED_YEAR = /(?::(?:19|20)\d{2}|\((?:\d{1,2}\/|R)?(?:19|20)\d{2}\))(?![0-9])(?=[^-]*$)/g;
29
+ const YEAR = /^(?:19|20)\d{2}$/;
26
30
  /**
27
- * The undated lane from a norm key: every `:?`-year not followed by a
28
- * dash is stripped — globally, base and supplement years alike. Ruby's
29
- * `gsub(/:?(?:19|20)\d{2}(?=[^-]*$)/, "")` verbatim.
31
+ * The undated lane from a norm key: every delimited year not followed by
32
+ * a dash is stripped — globally, base and supplement years alike. A year
33
+ * is delimited when a colon introduces it (`:2015`) or when it is a whole
34
+ * parenthesized date (`(2001)`, `(10/2019)`, the reaffirmation
35
+ * `(R2020)`). No digit continues the year, and a bare digit run is never
36
+ * a year: `ISO19115`, `RFC2045` and `IEC62019` stay whole.
30
37
  */
31
38
  export function undatedNorm(normKey) {
32
- return normKey.replace(/:?(?:19|20)\d{2}(?=[^-]*$)/g, "");
39
+ return normKey.replace(DELIMITED_YEAR, "");
40
+ }
41
+ /** The years that the parse gives: the identifier's own, then each
42
+ * base's (a supplement keeps its base year on the base record). */
43
+ function parsedYears(components) {
44
+ const years = [];
45
+ let record = components;
46
+ while (record !== undefined && record !== null && typeof record === "object" && !Array.isArray(record)) {
47
+ const year = yearText(record["year"]);
48
+ if (year !== undefined && YEAR.test(year))
49
+ years.push(year);
50
+ record = record["base"];
51
+ }
52
+ return years;
53
+ }
54
+ /** Each parsed year's first `-<year>` (the IEEE `802.3-2015/COR.1-2017`
55
+ * form) stripped from the dated key. No digit and no colon continues
56
+ * the match, so `11073-20101` and a part equal to the year
57
+ * (`ISO 8000-2019:2019`) stay. */
58
+ function stripParsedDashYears(dated, years) {
59
+ return years.reduce((key, year) => key.replace(new RegExp(`-${year}(?![0-9:])`), ""), dated);
60
+ }
61
+ function yearText(raw) {
62
+ if (typeof raw === "number")
63
+ return String(raw);
64
+ return facetText(raw);
33
65
  }
34
66
  function stripTrailingSegment(undated, segment) {
35
67
  const digitBoundary = /[0-9]$/.test(segment) ? "(?![0-9])" : "";
@@ -95,10 +127,11 @@ function structuralSubpart(components) {
95
127
  return record === undefined ? undefined : facetText(record["subpart"]);
96
128
  }
97
129
  /** The lane keys for an already-canonical record: norm from the render,
98
- * undated from the norm, all_parts from the parsed part and subpart. */
130
+ * undated from the norm and the parsed year, all_parts from the parsed
131
+ * part and subpart. */
99
132
  export function laneKeysFrom(canonical, components) {
100
133
  const dated = norm(canonical);
101
- const undated = undatedNorm(dated);
134
+ const undated = undatedNorm(stripParsedDashYears(dated, parsedYears(components)));
102
135
  return {
103
136
  dated,
104
137
  undated,