marc-ts 0.1.0 → 0.2.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as p, t as S } from "./types-c4Mo9m9u.js";
2
- var K = 27, v = "�", P = /* @__PURE__ */ new Map([
2
+ var V = 27, m = "�", G = /* @__PURE__ */ new Map([
3
3
  [33, "Ł"],
4
4
  [34, "Ø"],
5
5
  [35, "Đ"],
@@ -28,7 +28,7 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
28
28
  [59, "ơ"],
29
29
  [60, "ư"],
30
30
  [63, "°"]
31
- ]), G = /* @__PURE__ */ new Map([
31
+ ]), k = /* @__PURE__ */ new Map([
32
32
  [96, "̉"],
33
33
  [97, "̀"],
34
34
  [98, "́"],
@@ -58,7 +58,7 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
58
58
  [122, "︢"],
59
59
  [123, "︣"],
60
60
  [126, "̓"]
61
- ]), V = new Map(Array.from(G.entries()).map(([e, t]) => [t, e + 128])), X = new Map(Array.from(P.entries()).map(([e, t]) => [t, e + 128])), Q = M(65, "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", 97, "αβγδεζηθικλμνξοπρστυφχψω"), ee = M(96, "אבגדהוזחטיךכלםמןנסעףפץצקרשת"), te = M(65, "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 97, "абвгдежзийклмнопрстуфхцчшщъыьэюя"), ne = /* @__PURE__ */ new Map([
61
+ ]), X = new Map(Array.from(k.entries()).map(([e, t]) => [t, e + 128])), Q = new Map(Array.from(G.entries()).map(([e, t]) => [t, e + 128])), ee = M(65, "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", 97, "αβγδεζηθικλμνξοπρστυφχψω"), te = M(96, "אבגדהוזחטיךכלםמןנסעףפץצקרשת"), ne = M(65, "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 97, "абвгдежзийклмнопрстуфхцчшщъыьэюя"), re = /* @__PURE__ */ new Map([
62
62
  [33, "ء"],
63
63
  [34, "آ"],
64
64
  [35, "أ"],
@@ -95,7 +95,7 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
95
95
  [72, "و"],
96
96
  [73, "ى"],
97
97
  [74, "ي"]
98
- ]), re = /* @__PURE__ */ new Map([
98
+ ]), ie = /* @__PURE__ */ new Map([
99
99
  [40, "₍"],
100
100
  [41, "₎"],
101
101
  [43, "₊"],
@@ -110,7 +110,7 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
110
110
  [55, "₇"],
111
111
  [56, "₈"],
112
112
  [57, "₉"]
113
- ]), ie = /* @__PURE__ */ new Map([
113
+ ]), se = /* @__PURE__ */ new Map([
114
114
  [40, "⁽"],
115
115
  [41, "⁾"],
116
116
  [43, "⁺"],
@@ -126,7 +126,7 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
126
126
  [56, "⁸"],
127
127
  [57, "⁹"],
128
128
  [110, "ⁿ"]
129
- ]), se = /* @__PURE__ */ new Map([
129
+ ]), oe = /* @__PURE__ */ new Map([
130
130
  [2171169, "一"],
131
131
  [2171170, "丁"],
132
132
  [2171171, "七"],
@@ -161,15 +161,15 @@ var K = 27, v = "�", P = /* @__PURE__ */ new Map([
161
161
  [2171200, "丫"],
162
162
  [2171201, "中"],
163
163
  [2171202, "丰"]
164
- ]), oe = {
164
+ ]), ae = {
165
165
  ascii: /* @__PURE__ */ new Map(),
166
- ansel: ae(P, G),
167
- greek: Q,
168
- hebrew: ee,
169
- cyrillic: te,
170
- arabic: ne,
171
- subscript: re,
172
- superscript: ie
166
+ ansel: ce(G, k),
167
+ greek: ee,
168
+ hebrew: te,
169
+ cyrillic: ne,
170
+ arabic: re,
171
+ subscript: ie,
172
+ superscript: se
173
173
  };
174
174
  function M(...e) {
175
175
  const t = /* @__PURE__ */ new Map();
@@ -179,7 +179,7 @@ function M(...e) {
179
179
  }
180
180
  return t;
181
181
  }
182
- function ae(...e) {
182
+ function ce(...e) {
183
183
  const t = /* @__PURE__ */ new Map();
184
184
  for (const n of e) for (const [r, i] of n) t.set(r, i);
185
185
  return t;
@@ -191,24 +191,24 @@ function T(e) {
191
191
  function N(e, t) {
192
192
  return t ? e - 128 : e;
193
193
  }
194
- function ce(e, t, n) {
194
+ function le(e, t, n) {
195
195
  const r = N(e, n);
196
- return t === "ascii" ? r >= 32 && r <= 126 ? String.fromCharCode(r) : v : oe[t].get(r) ?? v;
196
+ return t === "ascii" ? r >= 32 && r <= 126 ? String.fromCharCode(r) : m : ae[t].get(r) ?? m;
197
197
  }
198
- function le(e, t, n) {
198
+ function de(e, t, n) {
199
199
  if (t + 2 >= e.length) return {
200
- char: v,
200
+ char: m,
201
201
  next: e.length
202
202
  };
203
203
  const r = N(e[t], n), i = N(e[t + 1], n), s = N(e[t + 2], n), o = r << 16 | i << 8 | s;
204
204
  return {
205
- char: se.get(o) ?? v,
205
+ char: oe.get(o) ?? m,
206
206
  next: t + 3
207
207
  };
208
208
  }
209
- function de(e, t, n) {
209
+ function fe(e, t, n) {
210
210
  if (t + 1 >= e.length) return {
211
- char: v,
211
+ char: m,
212
212
  next: e.length
213
213
  };
214
214
  const r = e[t + 1];
@@ -220,39 +220,39 @@ function de(e, t, n) {
220
220
  else if (r === 36) {
221
221
  const l = e[t + 2];
222
222
  if (l === void 0) return {
223
- char: v,
223
+ char: m,
224
224
  next: e.length
225
225
  };
226
226
  l === 40 || l === 44 ? (i = "g0", s = t + 3) : l === 41 || l === 45 ? (i = "g1", s = t + 3) : (i = "g0", s = t + 2);
227
227
  } else return {
228
- char: v,
228
+ char: m,
229
229
  next: t + 2
230
230
  };
231
231
  if (s >= e.length) return {
232
- char: v,
232
+ char: m,
233
233
  next: e.length
234
234
  };
235
235
  let o = e[s];
236
236
  if (o === 33) {
237
237
  if (s++, s >= e.length) return {
238
- char: v,
238
+ char: m,
239
239
  next: e.length
240
240
  };
241
241
  o = e[s];
242
242
  }
243
- const c = ue(o);
243
+ const c = ge(o);
244
244
  return c ? {
245
245
  char: "",
246
- next: fe(n, i, c, s + 1)
246
+ next: ue(n, i, c, s + 1)
247
247
  } : {
248
- char: v,
248
+ char: m,
249
249
  next: s + 1
250
250
  };
251
251
  }
252
- function fe(e, t, n, r) {
252
+ function ue(e, t, n, r) {
253
253
  return e[t] = n, r;
254
254
  }
255
- function ue(e) {
255
+ function ge(e) {
256
256
  switch (e) {
257
257
  case 49:
258
258
  return "eacc";
@@ -280,7 +280,7 @@ function ue(e) {
280
280
  return;
281
281
  }
282
282
  }
283
- function ge(e) {
283
+ function he(e) {
284
284
  const t = {
285
285
  g0: "ascii",
286
286
  g1: "ansel"
@@ -297,8 +297,8 @@ function ge(e) {
297
297
  };
298
298
  for (; i < e.length; ) {
299
299
  const o = e[i];
300
- if (o === K) {
301
- const d = de(e, i, t);
300
+ if (o === V) {
301
+ const d = fe(e, i, t);
302
302
  s(d.char), i = d.next;
303
303
  continue;
304
304
  }
@@ -308,18 +308,18 @@ function ge(e) {
308
308
  }
309
309
  const c = o >= 160, l = c ? t.g1 : t.g0;
310
310
  if (l === "eacc") {
311
- const d = le(e, i, c);
311
+ const d = de(e, i, c);
312
312
  s(d.char), i = d.next;
313
313
  continue;
314
314
  }
315
- s(ce(o, l, c)), i++;
315
+ s(le(o, l, c)), i++;
316
316
  }
317
317
  return r && n.push(r), n.join("");
318
318
  }
319
- function Te(e) {
320
- return k(e).bytes;
319
+ function De(e) {
320
+ return W(e).bytes;
321
321
  }
322
- function k(e) {
322
+ function W(e) {
323
323
  const t = e.normalize("NFD"), n = [];
324
324
  let r = 0, i = 0;
325
325
  for (; i < t.length; ) {
@@ -331,12 +331,12 @@ function k(e) {
331
331
  let c = i + (s > 65535 ? 2 : 1);
332
332
  const l = [];
333
333
  for (; c < t.length && T(t[c]); ) {
334
- const d = V.get(t[c]);
334
+ const d = X.get(t[c]);
335
335
  d !== void 0 ? l.push(d) : (l.push(63), r++), c++;
336
336
  }
337
337
  if (n.push(...l), s < 128) n.push(s);
338
338
  else {
339
- const d = X.get(o);
339
+ const d = Q.get(o);
340
340
  d !== void 0 ? n.push(d) : (n.push(63), r++);
341
341
  }
342
342
  i = c;
@@ -346,17 +346,17 @@ function k(e) {
346
346
  lossyCount: r
347
347
  };
348
348
  }
349
- var D = 31, W = 30, I = 24, C = 12, _ = 3, U = 4, R = new TextDecoder("utf-8", { fatal: !1 });
350
- function H(e) {
351
- return R.decode(e);
349
+ var D = 31, H = 30, y = 24, C = 12, _ = 3, U = 4, F = new TextDecoder("utf-8", { fatal: !1 });
350
+ function J(e) {
351
+ return F.decode(e);
352
352
  }
353
- function J(e, t = 16) {
353
+ function j(e, t = 16) {
354
354
  const n = e.slice(0, t), r = Array.from(n, (i) => i.toString(16).padStart(2, "0")).join(" ");
355
355
  return e.length > t ? `${r} … (${e.length} bytes)` : r;
356
356
  }
357
- function he(e, t = {}) {
357
+ function O(e, t = {}) {
358
358
  const n = t.strict ?? !1, r = t.maxWarnings ?? 100, i = [];
359
- if (e.length < I + 1) {
359
+ if (e.length < y + 1) {
360
360
  const a = g("truncated_record", `Record too short: ${e.length} bytes`);
361
361
  if (n) throw new Error(a.message);
362
362
  return i.push(a), {
@@ -364,8 +364,8 @@ function he(e, t = {}) {
364
364
  warnings: i
365
365
  };
366
366
  }
367
- const s = pe(e);
368
- if (!we(s, i, n) && (n || i.length >= r))
367
+ const s = we(e);
368
+ if (!Ee(s, i, n) && (n || i.length >= r))
369
369
  return {
370
370
  record: null,
371
371
  warnings: i
@@ -389,7 +389,7 @@ function he(e, t = {}) {
389
389
  warnings: i
390
390
  };
391
391
  }
392
- const l = I, d = e.indexOf(W, l);
392
+ const l = y, d = e.indexOf(H, l);
393
393
  if (d === -1) {
394
394
  const a = g("invalid_directory", "Directory terminator not found");
395
395
  if (n) throw new Error(a.message);
@@ -398,7 +398,7 @@ function he(e, t = {}) {
398
398
  warnings: i
399
399
  };
400
400
  }
401
- const u = Ee(e.slice(l, d), i, n, r);
401
+ const u = ve(e.slice(l, d), i, n, r);
402
402
  if (u.length === 0) {
403
403
  const a = g("invalid_directory", "No directory entries found");
404
404
  if (n) throw new Error(a.message);
@@ -416,23 +416,36 @@ function he(e, t = {}) {
416
416
  return {
417
417
  record: {
418
418
  leader: s,
419
- fields: me(e, u, c, f ? ge : (a) => R.decode(a), i, n, r)
419
+ fields: me(e, u, c, f ? he : (a) => F.decode(a), i, n, r)
420
420
  },
421
421
  warnings: i
422
422
  };
423
423
  }
424
- function Me(e) {
425
- const t = he(e, { strict: !0 });
426
- if (!t.record) throw new Error("Failed to parse MARC record in strict mode");
427
- return t.record;
424
+ var pe = 29;
425
+ function Ue(e, t) {
426
+ const n = [];
427
+ let r = 0;
428
+ for (let i = 0; i < e.length; i++) if (e[i] === pe) {
429
+ const s = e.slice(r, i + 1);
430
+ if (s.length > 0) {
431
+ const o = O(s, t);
432
+ o.record && n.push(o.record);
433
+ }
434
+ r = i + 1;
435
+ }
436
+ if (r < e.length) {
437
+ const i = O(e.slice(r), t);
438
+ i.record && n.push(i.record);
439
+ }
440
+ return n;
428
441
  }
429
- function pe(e) {
430
- const t = e.slice(0, I);
431
- return R.decode(t);
442
+ function we(e) {
443
+ const t = e.slice(0, y);
444
+ return F.decode(t);
432
445
  }
433
- function we(e, t, n) {
434
- if (e.length !== I) {
435
- const r = g("invalid_leader", `Leader length is ${e.length}, expected ${I}`);
446
+ function Ee(e, t, n) {
447
+ if (e.length !== y) {
448
+ const r = g("invalid_leader", `Leader length is ${e.length}, expected ${y}`);
436
449
  if (n) throw new Error(r.message);
437
450
  return t.push(r), !1;
438
451
  }
@@ -446,7 +459,7 @@ function we(e, t, n) {
446
459
  }
447
460
  return !0;
448
461
  }
449
- function Ee(e, t, n, r) {
462
+ function ve(e, t, n, r) {
450
463
  const i = [];
451
464
  for (let s = 0; s < e.length; s += C) {
452
465
  if (t.length >= r) {
@@ -454,7 +467,7 @@ function Ee(e, t, n, r) {
454
467
  break;
455
468
  }
456
469
  if (s + C > e.length) break;
457
- const o = e.slice(s, s + C), c = R.decode(o), l = c.substring(0, _), d = c.substring(_, _ + U), u = c.substring(_ + U, C), f = parseInt(d, 10), a = parseInt(u, 10);
470
+ const o = e.slice(s, s + C), c = F.decode(o), l = c.substring(0, _), d = c.substring(_, _ + U), u = c.substring(_ + U, C), f = parseInt(d, 10), a = parseInt(u, 10);
458
471
  if (isNaN(f) || isNaN(a)) {
459
472
  const w = g("invalid_directory", `Invalid directory entry for tag ${l}: length=${d}, position=${u}`);
460
473
  if (n) throw new Error(w.message);
@@ -484,7 +497,7 @@ function me(e, t, n, r, i, s, o) {
484
497
  continue;
485
498
  }
486
499
  let f;
487
- if (e[u] !== W) {
500
+ if (e[u] !== H) {
488
501
  const a = g("invalid_field", `Field ${l.tag} does not end with a field terminator at byte ${u} (found 0x${(e[u] ?? 0).toString(16).padStart(2, "0")}); using the full declared length without stripping a terminator byte.`, d, l.tag);
489
502
  if (s) throw new Error(a.message);
490
503
  i.push(a), f = e.slice(d, d + l.fieldLength);
@@ -497,11 +510,11 @@ function me(e, t, n, r, i, s, o) {
497
510
  data: a
498
511
  });
499
512
  } catch (a) {
500
- const w = g("encoding_error", `Failed to decode control field ${l.tag}: ${a instanceof Error ? a.message : String(a)}. Raw bytes (hex): ${J(f)}.`, d, l.tag);
513
+ const w = g("encoding_error", `Failed to decode control field ${l.tag}: ${a instanceof Error ? a.message : String(a)}. Raw bytes (hex): ${j(f)}.`, d, l.tag);
501
514
  if (s) throw new Error(w.message);
502
515
  i.push(w), c.push({
503
516
  tag: l.tag,
504
- data: H(f)
517
+ data: J(f)
505
518
  });
506
519
  }
507
520
  continue;
@@ -513,12 +526,12 @@ function me(e, t, n, r, i, s, o) {
513
526
  continue;
514
527
  }
515
528
  try {
516
- const a = String.fromCharCode(f[0] ?? 0), w = String.fromCharCode(f[1] ?? 0), y = ve(f.slice(2), r, l.tag, i, s, o);
529
+ const a = String.fromCharCode(f[0] ?? 0), w = String.fromCharCode(f[1] ?? 0), I = Se(f.slice(2), r, l.tag, i, s, o);
517
530
  c.push({
518
531
  tag: l.tag,
519
532
  indicator1: a,
520
533
  indicator2: w,
521
- subfields: y
534
+ subfields: I
522
535
  });
523
536
  } catch (a) {
524
537
  const w = g("invalid_field", `Failed to parse data field ${l.tag}: ${a instanceof Error ? a.message : String(a)}`, d, l.tag);
@@ -528,7 +541,7 @@ function me(e, t, n, r, i, s, o) {
528
541
  }
529
542
  return c;
530
543
  }
531
- function ve(e, t, n, r, i, s) {
544
+ function Se(e, t, n, r, i, s) {
532
545
  const o = [];
533
546
  let c = 0;
534
547
  for (; c < e.length; ) {
@@ -555,11 +568,11 @@ function ve(e, t, n, r, i, s) {
555
568
  value: f
556
569
  });
557
570
  } catch (f) {
558
- const a = g("encoding_error", `Failed to decode subfield ${n}$${l}: ${f instanceof Error ? f.message : String(f)}. Raw bytes (hex): ${J(u)}.`, void 0, n);
571
+ const a = g("encoding_error", `Failed to decode subfield ${n}$${l}: ${f instanceof Error ? f.message : String(f)}. Raw bytes (hex): ${j(u)}.`, void 0, n);
559
572
  if (i) throw new Error(a.message);
560
573
  r.push(a), o.push({
561
574
  code: l,
562
- value: H(u)
575
+ value: J(u)
563
576
  });
564
577
  }
565
578
  }
@@ -573,7 +586,7 @@ function g(e, t, n, r) {
573
586
  tag: r
574
587
  };
575
588
  }
576
- function Se(e, t, n, r) {
589
+ function be(e, t, n, r) {
577
590
  return {
578
591
  type: e,
579
592
  message: t,
@@ -581,29 +594,29 @@ function Se(e, t, n, r) {
581
594
  tag: r
582
595
  };
583
596
  }
584
- var be = 31, O = 30, $e = 29, F = 24, Ae = 3, Ie = 4, ye = 5;
585
- function De(e, t = {}) {
586
- return Ce(e, t).bytes;
597
+ var $e = 31, B = 30, Ae = 29, R = 24, ye = 3, Ie = 4, Ce = 5;
598
+ function _e(e, t = {}) {
599
+ return Ne(e, t).bytes;
587
600
  }
588
- function Ce(e, t = {}) {
589
- _e(e);
601
+ function Ne(e, t = {}) {
602
+ Re(e);
590
603
  const n = [], r = t.encoding === "marc8", i = new TextEncoder(), s = r ? (E, b) => {
591
- const $ = k(E);
592
- return $.lossyCount > 0 && n.push(Se("encoding_error", `MARC-8 encoding substituted ${$.lossyCount} character(s) with '?' because they have no MARC-8 equivalent.`, void 0, b)), $.bytes;
604
+ const $ = W(E);
605
+ return $.lossyCount > 0 && n.push(be("encoding_error", `MARC-8 encoding substituted ${$.lossyCount} character(s) with '?' because they have no MARC-8 equivalent.`, void 0, b)), $.bytes;
593
606
  } : (E) => i.encode(E), o = [], c = [];
594
607
  let l = 0;
595
608
  for (const E of e.fields) {
596
- const b = Ne(E, (Z) => s(Z, E.tag)), $ = b.length + 1, q = E.tag.padEnd(Ae, " ") + $.toString().padStart(Ie, "0") + l.toString().padStart(ye, "0");
597
- o.push(q), c.push(b), c.push(new Uint8Array([O])), l += $;
609
+ const b = Fe(E, (K) => s(K, E.tag)), $ = b.length + 1, Z = E.tag.padEnd(ye, " ") + $.toString().padStart(Ie, "0") + l.toString().padStart(Ce, "0");
610
+ o.push(Z), c.push(b), c.push(new Uint8Array([B])), l += $;
598
611
  }
599
612
  const d = i.encode(o.join("")), u = new Uint8Array(d.length + 1);
600
- u.set(d), u[d.length] = O;
601
- const f = F + u.length, a = c.reduce((E, b) => E + b.length, 0), w = new Uint8Array(a);
602
- let y = 0;
613
+ u.set(d), u[d.length] = B;
614
+ const f = R + u.length, a = c.reduce((E, b) => E + b.length, 0), w = new Uint8Array(a);
615
+ let I = 0;
603
616
  for (const E of c)
604
- w.set(E, y), y += E.length;
605
- const x = f + a + 1, Y = Fe(e.leader, x, f, r), A = new Uint8Array(x);
606
- return A.set(i.encode(Y), 0), A.set(u, F), A.set(w, f), A[x - 1] = $e, {
617
+ w.set(E, I), I += E.length;
618
+ const x = f + a + 1, q = xe(e.leader, x, f, r), A = new Uint8Array(x);
619
+ return A.set(i.encode(q), 0), A.set(u, R), A.set(w, f), A[x - 1] = Ae, {
607
620
  bytes: A,
608
621
  warnings: n
609
622
  };
@@ -612,7 +625,7 @@ function L(e) {
612
625
  const t = e.charCodeAt(0);
613
626
  return t >= 32 && t <= 126;
614
627
  }
615
- function _e(e) {
628
+ function Re(e) {
616
629
  for (const t of e.fields) {
617
630
  if (typeof t.tag != "string" || t.tag.length !== 3) throw new Error(`MARC field tag must be exactly 3 characters; got ${JSON.stringify(t.tag)}`);
618
631
  if (!S(t)) {
@@ -627,11 +640,11 @@ function _e(e) {
627
640
  }
628
641
  }
629
642
  }
630
- function Ne(e, t) {
643
+ function Fe(e, t) {
631
644
  if (S(e)) return t(e.data);
632
645
  const n = [new Uint8Array([e.indicator1.charCodeAt(0), e.indicator2.charCodeAt(0)])];
633
646
  for (const o of e.subfields) {
634
- const c = new Uint8Array([be, o.code.charCodeAt(0)]);
647
+ const c = new Uint8Array([$e, o.code.charCodeAt(0)]);
635
648
  n.push(c, t(o.value));
636
649
  }
637
650
  const r = n.reduce((o, c) => o + c.length, 0), i = new Uint8Array(r);
@@ -640,8 +653,8 @@ function Ne(e, t) {
640
653
  i.set(o, s), s += o.length;
641
654
  return i;
642
655
  }
643
- function Fe(e, t, n, r) {
644
- let i = e.padEnd(F, " ").substring(0, F);
656
+ function xe(e, t, n, r) {
657
+ let i = e.padEnd(R, " ").substring(0, R);
645
658
  const s = t.toString().padStart(5, "0");
646
659
  if (s.length > 5) throw new Error(`Record length ${t} exceeds maximum (99999)`);
647
660
  i = s + i.substring(5);
@@ -649,65 +662,72 @@ function Fe(e, t, n, r) {
649
662
  if (o.length > 5) throw new Error(`Base address ${n} exceeds maximum (99999)`);
650
663
  return i = i.substring(0, 12) + o + i.substring(17), i = i.substring(0, 9) + (r ? " " : "a") + i.substring(10), i;
651
664
  }
652
- function m(e, t) {
665
+ function Oe(e, t = {}) {
666
+ const n = e.map((o) => _e(o, t)), r = n.reduce((o, c) => o + c.length, 0), i = new Uint8Array(r);
667
+ let s = 0;
668
+ for (const o of n)
669
+ i.set(o, s), s += o.length;
670
+ return i;
671
+ }
672
+ function v(e, t) {
653
673
  return e.fields.find((n) => n.tag === t);
654
674
  }
655
- function Ue(e, t) {
675
+ function Be(e, t) {
656
676
  return e.fields.filter((n) => n.tag === t);
657
677
  }
658
678
  function h(e, t) {
659
679
  return e.subfields.find((n) => n.code === t)?.value;
660
680
  }
661
- function Oe(e, t) {
681
+ function Pe(e, t) {
662
682
  return e.subfields.filter((n) => n.code === t).map((n) => n.value);
663
683
  }
664
- function Be(e) {
684
+ function Ge(e) {
665
685
  return e.subfields.map((t) => ({
666
686
  code: t.code,
667
687
  value: t.value
668
688
  }));
669
689
  }
670
- function Pe(e) {
671
- const t = m(e, "245");
690
+ function ke(e) {
691
+ const t = v(e, "245");
672
692
  if (!t || !p(t)) return;
673
693
  const n = h(t, "a") ?? "", r = h(t, "b") ?? "";
674
694
  return (n + " " + r).trim() || void 0;
675
695
  }
676
- function Ge(e) {
677
- const t = m(e, "245");
696
+ function We(e) {
697
+ const t = v(e, "245");
678
698
  if (!(!t || !p(t)))
679
699
  return h(t, "a");
680
700
  }
681
- function ke(e) {
682
- const t = m(e, "100");
701
+ function He(e) {
702
+ const t = v(e, "100");
683
703
  if (t && p(t)) return h(t, "a");
684
- const n = m(e, "110");
704
+ const n = v(e, "110");
685
705
  if (n && p(n)) return h(n, "a");
686
706
  }
687
- function We(e) {
688
- const t = m(e, "250");
707
+ function Je(e) {
708
+ const t = v(e, "250");
689
709
  if (!(!t || !p(t)))
690
710
  return h(t, "a");
691
711
  }
692
- function He(e) {
693
- const t = m(e, "264");
712
+ function je(e) {
713
+ const t = v(e, "264");
694
714
  if (t && p(t)) {
695
715
  const r = h(t, "b");
696
716
  if (r) return r;
697
717
  }
698
- const n = m(e, "260");
718
+ const n = v(e, "260");
699
719
  if (n && p(n)) return h(n, "b");
700
720
  }
701
- function Je(e) {
702
- const t = m(e, "264");
721
+ function ze(e) {
722
+ const t = v(e, "264");
703
723
  if (t && p(t)) {
704
724
  const r = h(t, "c");
705
725
  if (r) return r;
706
726
  }
707
- const n = m(e, "260");
727
+ const n = v(e, "260");
708
728
  if (n && p(n)) return h(n, "c");
709
729
  }
710
- function je(e) {
730
+ function Ye(e) {
711
731
  const t = [];
712
732
  for (const n of e.fields) if (n.tag === "020" && p(n)) {
713
733
  const r = h(n, "a");
@@ -715,17 +735,17 @@ function je(e) {
715
735
  }
716
736
  return t;
717
737
  }
718
- function ze(e) {
719
- const t = m(e, "022");
738
+ function qe(e) {
739
+ const t = v(e, "022");
720
740
  if (!(!t || !p(t)))
721
741
  return h(t, "a");
722
742
  }
723
- function Ye(e) {
724
- const t = m(e, "010");
743
+ function Ze(e) {
744
+ const t = v(e, "010");
725
745
  if (!(!t || !p(t)))
726
746
  return h(t, "a");
727
747
  }
728
- function qe(e) {
748
+ function Ke(e) {
729
749
  const t = [];
730
750
  for (const n of e.fields) if (n.tag.startsWith("6") && p(n)) {
731
751
  const r = h(n, "a");
@@ -733,12 +753,12 @@ function qe(e) {
733
753
  }
734
754
  return t;
735
755
  }
736
- function Ze(e) {
737
- const t = m(e, "490");
756
+ function Ve(e) {
757
+ const t = v(e, "490");
738
758
  if (!(!t || !p(t)))
739
759
  return h(t, "a");
740
760
  }
741
- function j(e, t) {
761
+ function z(e, t) {
742
762
  if (e.length !== 3 || t.length !== 3) return !1;
743
763
  for (let n = 0; n < 3; n++) {
744
764
  const r = t[n], i = e[n];
@@ -750,37 +770,37 @@ function j(e, t) {
750
770
  }
751
771
  return !0;
752
772
  }
753
- function Ke(e, t) {
754
- return e.fields.filter((n) => j(n.tag, t));
773
+ function Xe(e, t) {
774
+ return e.fields.filter((n) => z(n.tag, t));
755
775
  }
756
- function Ve(e, t) {
757
- return e.fields.find((n) => j(n.tag, t));
776
+ function Qe(e, t) {
777
+ return e.fields.find((n) => z(n.tag, t));
758
778
  }
759
- function z(e, t) {
779
+ function Y(e, t) {
760
780
  return {
761
781
  ...e,
762
782
  fields: [...e.fields, t]
763
783
  };
764
784
  }
765
- function Xe(e, t, n) {
785
+ function et(e, t, n) {
766
786
  const r = e.fields.findIndex((s) => s.tag === t);
767
- if (r === -1) return z(e, n);
787
+ if (r === -1) return Y(e, n);
768
788
  const i = Array.from(e.fields);
769
789
  return i.splice(r, 0, n), {
770
790
  ...e,
771
791
  fields: i
772
792
  };
773
793
  }
774
- function Qe(e, t, n) {
794
+ function tt(e, t, n) {
775
795
  const r = e.fields.findIndex((s) => s.tag === t);
776
- if (r === -1) return z(e, n);
796
+ if (r === -1) return Y(e, n);
777
797
  const i = Array.from(e.fields);
778
798
  return i.splice(r + 1, 0, n), {
779
799
  ...e,
780
800
  fields: i
781
801
  };
782
802
  }
783
- function et(e, t) {
803
+ function nt(e, t) {
784
804
  const n = parseInt(t.tag, 10);
785
805
  let r = e.fields.length;
786
806
  for (let s = 0; s < e.fields.length; s++) {
@@ -796,19 +816,19 @@ function et(e, t) {
796
816
  fields: i
797
817
  };
798
818
  }
799
- function tt(e, t) {
819
+ function rt(e, t) {
800
820
  return {
801
821
  ...e,
802
822
  fields: e.fields.filter((n) => n.tag !== t)
803
823
  };
804
824
  }
805
- function nt(e, t) {
825
+ function it(e, t) {
806
826
  return {
807
827
  ...e,
808
828
  fields: e.fields.filter((n) => n !== t)
809
829
  };
810
830
  }
811
- function Re(e, t, n) {
831
+ function Le(e, t, n) {
812
832
  return {
813
833
  ...e,
814
834
  subfields: [...e.subfields, {
@@ -817,15 +837,15 @@ function Re(e, t, n) {
817
837
  }]
818
838
  };
819
839
  }
820
- function rt(e, t) {
840
+ function st(e, t) {
821
841
  return {
822
842
  ...e,
823
843
  subfields: e.subfields.filter((n) => n.code !== t)
824
844
  };
825
845
  }
826
- function it(e, t, n) {
846
+ function ot(e, t, n) {
827
847
  const r = e.subfields.findIndex((s) => s.code === t);
828
- if (r === -1) return Re(e, t, n);
848
+ if (r === -1) return Le(e, t, n);
829
849
  const i = [...e.subfields];
830
850
  return i[r] = {
831
851
  code: t,
@@ -835,7 +855,7 @@ function it(e, t, n) {
835
855
  subfields: i
836
856
  };
837
857
  }
838
- function st(e) {
858
+ function at(e) {
839
859
  const t = new Array(e.fields.length);
840
860
  for (let n = 0; n < e.fields.length; n++) {
841
861
  const r = e.fields[n];
@@ -865,16 +885,16 @@ function st(e) {
865
885
  fields: t
866
886
  };
867
887
  }
868
- function ot(e, t, n = !1) {
888
+ function ct(e, t, n = !1) {
869
889
  if (e.leader !== t.leader || e.fields.length !== t.fields.length) return !1;
870
- const r = n ? [...e.fields].sort(B) : e.fields, i = n ? [...t.fields].sort(B) : t.fields;
890
+ const r = n ? [...e.fields].sort(P) : e.fields, i = n ? [...t.fields].sort(P) : t.fields;
871
891
  for (let s = 0; s < r.length; s++) {
872
892
  const o = r[s], c = i[s];
873
- if (!o || !c || !xe(o, c)) return !1;
893
+ if (!o || !c || !Te(o, c)) return !1;
874
894
  }
875
895
  return !0;
876
896
  }
877
- function xe(e, t) {
897
+ function Te(e, t) {
878
898
  if (e.tag !== t.tag) return !1;
879
899
  if (S(e) && S(t)) return e.data === t.data;
880
900
  if (!S(e) && !S(t)) {
@@ -887,50 +907,48 @@ function xe(e, t) {
887
907
  }
888
908
  return !1;
889
909
  }
890
- function B(e, t) {
910
+ function P(e, t) {
891
911
  return e.tag.localeCompare(t.tag);
892
912
  }
893
913
  export {
894
- Re as addSubfield,
895
- z as appendField,
896
- ke as author,
897
- st as cloneRecord,
898
- Se as createWarning,
899
- We as edition,
900
- xe as fieldsEqual,
901
- Be as getAllSubfields,
902
- m as getField,
903
- Ue as getFields,
904
- Ke as getFieldsByPattern,
905
- Ve as getFirstFieldByPattern,
914
+ Le as addSubfield,
915
+ Y as appendField,
916
+ He as author,
917
+ at as cloneRecord,
918
+ be as createWarning,
919
+ Je as edition,
920
+ Te as fieldsEqual,
921
+ Ge as getAllSubfields,
922
+ v as getField,
923
+ Be as getFields,
924
+ Xe as getFieldsByPattern,
925
+ Qe as getFirstFieldByPattern,
906
926
  h as getSubfield,
907
- Oe as getSubfields,
908
- Qe as insertFieldAfter,
909
- Xe as insertFieldBefore,
910
- et as insertGroupedField,
927
+ Pe as getSubfields,
928
+ tt as insertFieldAfter,
929
+ et as insertFieldBefore,
930
+ nt as insertGroupedField,
911
931
  S as isControlField,
912
932
  p as isDataField,
913
- je as isbn,
914
- ze as issn,
915
- Ye as lccn,
916
- ge as marc8ToUnicode,
917
- he as parseMarcRecord,
918
- Me as parseMarcRecordStrict,
919
- Je as publicationDate,
920
- He as publisher,
921
- ot as recordsEqual,
922
- nt as removeField,
923
- tt as removeFields,
924
- rt as removeSubfield,
925
- it as replaceSubfield,
926
- De as serializeMarcRecord,
927
- Ce as serializeMarcRecordWithWarnings,
928
- Ze as seriesStatement,
929
- qe as subjects,
930
- Pe as title,
931
- Ge as titleProper,
932
- Te as unicodeToMarc8,
933
- k as unicodeToMarc8WithStats
933
+ Ye as isbn,
934
+ qe as issn,
935
+ Ze as lccn,
936
+ he as marc8ToUnicode,
937
+ Ue as parseMarcBinary,
938
+ ze as publicationDate,
939
+ je as publisher,
940
+ ct as recordsEqual,
941
+ it as removeField,
942
+ rt as removeFields,
943
+ st as removeSubfield,
944
+ ot as replaceSubfield,
945
+ Oe as serializeMarcBinary,
946
+ Ve as seriesStatement,
947
+ Ke as subjects,
948
+ ke as title,
949
+ We as titleProper,
950
+ De as unicodeToMarc8,
951
+ W as unicodeToMarc8WithStats
934
952
  };
935
953
 
936
954
  //# sourceMappingURL=index.js.map