asterix-parser 1.0.1 → 1.0.3

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * CAT 062의 가변 데이터 길이
3
+ * @param bitArr 비트 데이터
4
+ * @param recordIndex record 인덱스
5
+ * @param dataItem 데이터 아이템 이름
6
+ * @returns 각 데이터 아이템의 길이
7
+ */
8
+ declare const cat062VarLen: (bitArr: Uint8Array, recordIndex: number, dataItem: string) => number;
9
+ export { cat062VarLen };
@@ -0,0 +1,679 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cat062VarLen = void 0;
4
+ const preprocess_1 = require("../preprocess");
5
+ const common_1 = require("../common");
6
+ /**
7
+ * CAT 062의 가변 데이터 길이
8
+ * @param bitArr 비트 데이터
9
+ * @param recordIndex record 인덱스
10
+ * @param dataItem 데이터 아이템 이름
11
+ * @returns 각 데이터 아이템의 길이
12
+ */
13
+ const cat062VarLen = (bitArr, recordIndex, dataItem) => {
14
+ switch (dataItem) {
15
+ case "di080":
16
+ case "di270":
17
+ return checkLastBit(bitArr, recordIndex);
18
+ case "di110":
19
+ return di110Len(bitArr, recordIndex);
20
+ case "di290":
21
+ return di290Len(bitArr, recordIndex);
22
+ case "di295":
23
+ return di295Len(bitArr, recordIndex);
24
+ case "di340":
25
+ return di340Len(bitArr, recordIndex);
26
+ case "di380":
27
+ return di380Len(bitArr, recordIndex);
28
+ case "di390":
29
+ return di390Len(bitArr, recordIndex);
30
+ case "di500":
31
+ return di500Len(bitArr, recordIndex);
32
+ case "di510":
33
+ return di510Len(bitArr, recordIndex);
34
+ case "SP":
35
+ case "RE":
36
+ return spAndReLen(bitArr, recordIndex);
37
+ default:
38
+ return 0;
39
+ }
40
+ };
41
+ exports.cat062VarLen = cat062VarLen;
42
+ /**
43
+ * 마지막 비트를 보고 추가 확장이 있는지 판단
44
+ * CAT 062: 080
45
+ * @param bitArr 바이트 값
46
+ * @param recordIndex record 시작 인덱스
47
+ * @returns 데이터 길이
48
+ */
49
+ const checkLastBit = (bitArr, recordIndex) => {
50
+ // octet 개수
51
+ let octetCount = 0;
52
+ // 추가 확장 유무
53
+ let hasExtension = true;
54
+ while (hasExtension) {
55
+ const currentByte = bitArr[recordIndex++];
56
+ hasExtension = (currentByte & 1) != 0;
57
+ octetCount++;
58
+ }
59
+ return octetCount;
60
+ };
61
+ /**
62
+ * Primary Subfield를 통해 특정 Subfield가 추가
63
+ * Primary Subfield 최대 1개
64
+ * CAT 062: 295
65
+ * @param bitArr 바이트 값
66
+ * @param recordIndex record 시작 인덱스
67
+ * @returns 데이터 길이
68
+ */
69
+ const di110Len = (bitArr, recordIndex) => {
70
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
71
+ let diLength = headerLen;
72
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
73
+ // SUM
74
+ diLength += 1;
75
+ }
76
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
77
+ // PMN
78
+ diLength += 4;
79
+ }
80
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
81
+ // POS
82
+ diLength += 6;
83
+ }
84
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
85
+ // GA
86
+ diLength += 2;
87
+ }
88
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
89
+ // EM1
90
+ diLength += 2;
91
+ }
92
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
93
+ // TOS
94
+ diLength += 1;
95
+ }
96
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
97
+ // XP
98
+ diLength += 1;
99
+ }
100
+ return diLength;
101
+ };
102
+ /**
103
+ * Primary Subfield를 통해 특정 Subfield가 추가
104
+ * Primary Subfield 최대 1개
105
+ * CAT 062: 290
106
+ * @param bitArr 바이트 값
107
+ * @param recordIndex record 시작 인덱스
108
+ * @returns 데이터 길이
109
+ */
110
+ const di290Len = (bitArr, recordIndex) => {
111
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
112
+ let diLength = headerLen;
113
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
114
+ // TRK
115
+ diLength += 1;
116
+ }
117
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
118
+ // PSR
119
+ diLength += 1;
120
+ }
121
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
122
+ // SSR
123
+ diLength += 1;
124
+ }
125
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
126
+ // MDS
127
+ diLength += 1;
128
+ }
129
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
130
+ // ADS
131
+ diLength += 2;
132
+ }
133
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
134
+ // ES
135
+ diLength += 1;
136
+ }
137
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
138
+ // VDL
139
+ diLength += 1;
140
+ }
141
+ if ((0, common_1.isBitSet)(bits, 8, headerLen)) {
142
+ // UAT
143
+ diLength += 1;
144
+ }
145
+ if ((0, common_1.isBitSet)(bits, 9, headerLen)) {
146
+ // LOP
147
+ diLength += 1;
148
+ }
149
+ if ((0, common_1.isBitSet)(bits, 10, headerLen)) {
150
+ // MLT
151
+ diLength += 1;
152
+ }
153
+ return diLength;
154
+ };
155
+ /**
156
+ * Primary Subfield를 통해 특정 Subfield가 추가
157
+ * Primary Subfield 최대 1개
158
+ * CAT 062: 295
159
+ * @param bitArr 바이트 값
160
+ * @param recordIndex record 시작 인덱스
161
+ * @returns 데이터 길이
162
+ */
163
+ const di295Len = (bitArr, recordIndex) => {
164
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
165
+ let diLength = headerLen;
166
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
167
+ // MFL
168
+ diLength += 1;
169
+ }
170
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
171
+ // MD1
172
+ diLength += 1;
173
+ }
174
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
175
+ // MD2
176
+ diLength += 1;
177
+ }
178
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
179
+ // MDA
180
+ diLength += 1;
181
+ }
182
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
183
+ // MD4
184
+ diLength += 1;
185
+ }
186
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
187
+ // MD5
188
+ diLength += 1;
189
+ }
190
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
191
+ // MHG
192
+ diLength += 1;
193
+ }
194
+ if ((0, common_1.isBitSet)(bits, 8, headerLen)) {
195
+ // IAS
196
+ diLength += 1;
197
+ }
198
+ if ((0, common_1.isBitSet)(bits, 9, headerLen)) {
199
+ // TAS
200
+ diLength += 1;
201
+ }
202
+ if ((0, common_1.isBitSet)(bits, 10, headerLen)) {
203
+ // SAL
204
+ diLength += 1;
205
+ }
206
+ if ((0, common_1.isBitSet)(bits, 11, headerLen)) {
207
+ // FSS
208
+ diLength += 1;
209
+ }
210
+ if ((0, common_1.isBitSet)(bits, 12, headerLen)) {
211
+ // TID
212
+ diLength += 1;
213
+ }
214
+ if ((0, common_1.isBitSet)(bits, 13, headerLen)) {
215
+ // COM
216
+ diLength += 1;
217
+ }
218
+ if ((0, common_1.isBitSet)(bits, 14, headerLen)) {
219
+ // SAB
220
+ diLength += 1;
221
+ }
222
+ if ((0, common_1.isBitSet)(bits, 15, headerLen)) {
223
+ // ACS
224
+ diLength += 1;
225
+ }
226
+ if ((0, common_1.isBitSet)(bits, 16, headerLen)) {
227
+ // BVR
228
+ diLength += 1;
229
+ }
230
+ if ((0, common_1.isBitSet)(bits, 17, headerLen)) {
231
+ // GVR
232
+ diLength += 1;
233
+ }
234
+ if ((0, common_1.isBitSet)(bits, 18, headerLen)) {
235
+ // RAN
236
+ diLength += 1;
237
+ }
238
+ if ((0, common_1.isBitSet)(bits, 19, headerLen)) {
239
+ // TAR
240
+ diLength += 1;
241
+ }
242
+ if ((0, common_1.isBitSet)(bits, 20, headerLen)) {
243
+ // TAN
244
+ diLength += 1;
245
+ }
246
+ if ((0, common_1.isBitSet)(bits, 21, headerLen)) {
247
+ // GSP
248
+ diLength += 1;
249
+ }
250
+ if ((0, common_1.isBitSet)(bits, 22, headerLen)) {
251
+ // VUN
252
+ diLength += 1;
253
+ }
254
+ if ((0, common_1.isBitSet)(bits, 23, headerLen)) {
255
+ // MET
256
+ diLength += 1;
257
+ }
258
+ if ((0, common_1.isBitSet)(bits, 24, headerLen)) {
259
+ // EMC
260
+ diLength += 1;
261
+ }
262
+ if ((0, common_1.isBitSet)(bits, 25, headerLen)) {
263
+ // POS
264
+ diLength += 1;
265
+ }
266
+ if ((0, common_1.isBitSet)(bits, 26, headerLen)) {
267
+ // GAL
268
+ diLength += 1;
269
+ }
270
+ if ((0, common_1.isBitSet)(bits, 27, headerLen)) {
271
+ // PUN
272
+ diLength += 1;
273
+ }
274
+ if ((0, common_1.isBitSet)(bits, 28, headerLen)) {
275
+ // MB
276
+ diLength += 1;
277
+ }
278
+ if ((0, common_1.isBitSet)(bits, 29, headerLen)) {
279
+ // IAR
280
+ diLength += 1;
281
+ }
282
+ if ((0, common_1.isBitSet)(bits, 30, headerLen)) {
283
+ // MAC
284
+ diLength += 1;
285
+ }
286
+ if ((0, common_1.isBitSet)(bits, 31, headerLen)) {
287
+ // BPS
288
+ diLength += 1;
289
+ }
290
+ return diLength;
291
+ };
292
+ /**
293
+ * Primary Subfield를 통해 특정 Subfield가 추가
294
+ * Primary Subfield 최대 1개
295
+ * CAT 062: 340
296
+ * @param bitArr 바이트 값
297
+ * @param recordIndex record 시작 인덱스
298
+ * @returns 데이터 길이
299
+ */
300
+ const di340Len = (bitArr, recordIndex) => {
301
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
302
+ let diLength = headerLen;
303
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
304
+ // SID
305
+ diLength += 2;
306
+ }
307
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
308
+ // POS
309
+ diLength += 4;
310
+ }
311
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
312
+ // HEI
313
+ diLength += 2;
314
+ }
315
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
316
+ // MDC
317
+ diLength += 2;
318
+ }
319
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
320
+ // MDA
321
+ diLength += 2;
322
+ }
323
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
324
+ // TYP
325
+ diLength += 1;
326
+ }
327
+ return diLength;
328
+ };
329
+ /**
330
+ * Primary Subfield를 통해 특정 Subfield가 추가
331
+ * Primary Subfield 최대 4개
332
+ * CAT 062: 380
333
+ * @param bitArr 바이트 값
334
+ * @param recordIndex record 시작 인덱스
335
+ * @returns 데이터 길이
336
+ */
337
+ const di380Len = (bitArr, recordIndex) => {
338
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
339
+ // 헤더 길이
340
+ let diLength = headerLen;
341
+ // 실제 데이터 시작 위치
342
+ let dataStartIndex = recordIndex + headerLen;
343
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
344
+ // ADR
345
+ diLength += 3;
346
+ dataStartIndex += 3;
347
+ }
348
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
349
+ // ID
350
+ // 반복 횟수
351
+ diLength += 6;
352
+ dataStartIndex += 6;
353
+ }
354
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
355
+ // MHG
356
+ diLength += 2;
357
+ dataStartIndex += 2;
358
+ }
359
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
360
+ // IAS
361
+ diLength += 2;
362
+ dataStartIndex += 2;
363
+ }
364
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
365
+ // TAS
366
+ diLength += 2;
367
+ dataStartIndex += 2;
368
+ }
369
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
370
+ // SAL
371
+ diLength += 2;
372
+ dataStartIndex += 2;
373
+ }
374
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
375
+ // FSS
376
+ diLength += 2;
377
+ dataStartIndex += 2;
378
+ }
379
+ if ((0, common_1.isBitSet)(bits, 8, headerLen)) {
380
+ // TIS
381
+ diLength += 1;
382
+ dataStartIndex += 1;
383
+ }
384
+ if ((0, common_1.isBitSet)(bits, 9, headerLen)) {
385
+ // TID
386
+ // 반복 횟수
387
+ const rep = bitArr[dataStartIndex];
388
+ diLength += (1 + (rep * 15));
389
+ dataStartIndex += (1 + (rep * 15));
390
+ }
391
+ if ((0, common_1.isBitSet)(bits, 10, headerLen)) {
392
+ // COM
393
+ diLength += 2;
394
+ dataStartIndex += 2;
395
+ }
396
+ if ((0, common_1.isBitSet)(bits, 11, headerLen)) {
397
+ // SAB
398
+ diLength += 2;
399
+ dataStartIndex += 2;
400
+ }
401
+ if ((0, common_1.isBitSet)(bits, 12, headerLen)) {
402
+ // ACS
403
+ diLength += 7;
404
+ dataStartIndex += 7;
405
+ }
406
+ if ((0, common_1.isBitSet)(bits, 13, headerLen)) {
407
+ // BVR
408
+ diLength += 2;
409
+ dataStartIndex += 2;
410
+ }
411
+ if ((0, common_1.isBitSet)(bits, 14, headerLen)) {
412
+ // GVR
413
+ diLength += 2;
414
+ dataStartIndex += 2;
415
+ }
416
+ if ((0, common_1.isBitSet)(bits, 15, headerLen)) {
417
+ // RAN
418
+ diLength += 2;
419
+ dataStartIndex += 2;
420
+ }
421
+ if ((0, common_1.isBitSet)(bits, 16, headerLen)) {
422
+ // TAR
423
+ diLength += 2;
424
+ dataStartIndex += 2;
425
+ }
426
+ if ((0, common_1.isBitSet)(bits, 17, headerLen)) {
427
+ // TAN
428
+ diLength += 2;
429
+ dataStartIndex += 2;
430
+ }
431
+ if ((0, common_1.isBitSet)(bits, 18, headerLen)) {
432
+ // GSP
433
+ diLength += 2;
434
+ dataStartIndex += 2;
435
+ }
436
+ if ((0, common_1.isBitSet)(bits, 19, headerLen)) {
437
+ // VUN
438
+ diLength += 1;
439
+ dataStartIndex += 1;
440
+ }
441
+ if ((0, common_1.isBitSet)(bits, 20, headerLen)) {
442
+ // MET
443
+ diLength += 8;
444
+ dataStartIndex += 8;
445
+ }
446
+ if ((0, common_1.isBitSet)(bits, 21, headerLen)) {
447
+ // EMC
448
+ diLength += 1;
449
+ dataStartIndex += 1;
450
+ }
451
+ if ((0, common_1.isBitSet)(bits, 22, headerLen)) {
452
+ // POS
453
+ diLength += 6;
454
+ dataStartIndex += 6;
455
+ }
456
+ if ((0, common_1.isBitSet)(bits, 23, headerLen)) {
457
+ // GAL
458
+ diLength += 2;
459
+ dataStartIndex += 2;
460
+ }
461
+ if ((0, common_1.isBitSet)(bits, 24, headerLen)) {
462
+ // PUN
463
+ diLength += 1;
464
+ dataStartIndex += 1;
465
+ }
466
+ if ((0, common_1.isBitSet)(bits, 25, headerLen)) {
467
+ // MB
468
+ // 반복 횟수
469
+ const rep = bitArr[dataStartIndex];
470
+ diLength += (1 + (rep * 8));
471
+ dataStartIndex += (1 + (rep * 8));
472
+ }
473
+ if ((0, common_1.isBitSet)(bits, 26, headerLen)) {
474
+ // IAR
475
+ diLength += 2;
476
+ dataStartIndex += 2;
477
+ }
478
+ if ((0, common_1.isBitSet)(bits, 27, headerLen)) {
479
+ // MAC
480
+ diLength += 2;
481
+ dataStartIndex += 2;
482
+ }
483
+ if ((0, common_1.isBitSet)(bits, 28, headerLen)) {
484
+ // BPS
485
+ diLength += 2;
486
+ dataStartIndex += 2;
487
+ }
488
+ return diLength;
489
+ };
490
+ /**
491
+ * Primary Subfield를 통해 특정 Subfield가 추가
492
+ * Primary Subfield 최대 4개
493
+ * CAT 062: 390
494
+ * @param bitArr 바이트 값
495
+ * @param recordIndex record 시작 인덱스
496
+ * @returns 데이터 길이
497
+ */
498
+ const di390Len = (bitArr, recordIndex) => {
499
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
500
+ // 헤더 길이
501
+ let diLength = headerLen;
502
+ // 실제 데이터 시작 위치
503
+ let dataStartIndex = recordIndex + headerLen;
504
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
505
+ // TAG
506
+ diLength += 2;
507
+ dataStartIndex += 2;
508
+ }
509
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
510
+ // CSN
511
+ diLength += 7;
512
+ dataStartIndex += 7;
513
+ }
514
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
515
+ // IFI
516
+ diLength += 4;
517
+ dataStartIndex += 4;
518
+ }
519
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
520
+ // FCT
521
+ diLength += 1;
522
+ dataStartIndex += 1;
523
+ }
524
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
525
+ // TAC
526
+ diLength += 4;
527
+ dataStartIndex += 4;
528
+ }
529
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
530
+ // WTC
531
+ diLength += 1;
532
+ dataStartIndex += 1;
533
+ }
534
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
535
+ // DEP
536
+ diLength += 4;
537
+ dataStartIndex += 4;
538
+ }
539
+ if ((0, common_1.isBitSet)(bits, 8, headerLen)) {
540
+ // DST
541
+ diLength += 4;
542
+ dataStartIndex += 4;
543
+ }
544
+ if ((0, common_1.isBitSet)(bits, 9, headerLen)) {
545
+ // RDS
546
+ diLength += 3;
547
+ dataStartIndex += 3;
548
+ }
549
+ if ((0, common_1.isBitSet)(bits, 10, headerLen)) {
550
+ // CFL
551
+ diLength += 2;
552
+ dataStartIndex += 2;
553
+ }
554
+ if ((0, common_1.isBitSet)(bits, 11, headerLen)) {
555
+ // CTL
556
+ diLength += 2;
557
+ dataStartIndex += 2;
558
+ }
559
+ if ((0, common_1.isBitSet)(bits, 12, headerLen)) {
560
+ // TOD
561
+ // 반복 횟수
562
+ const rep = bitArr[dataStartIndex];
563
+ diLength += (1 + (rep * 4));
564
+ dataStartIndex += (1 + (rep * 4));
565
+ }
566
+ if ((0, common_1.isBitSet)(bits, 13, headerLen)) {
567
+ // AST
568
+ diLength += 6;
569
+ dataStartIndex += 6;
570
+ }
571
+ if ((0, common_1.isBitSet)(bits, 14, headerLen)) {
572
+ // STS
573
+ diLength += 1;
574
+ dataStartIndex += 1;
575
+ }
576
+ if ((0, common_1.isBitSet)(bits, 15, headerLen)) {
577
+ // STD
578
+ diLength += 7;
579
+ dataStartIndex += 7;
580
+ }
581
+ if ((0, common_1.isBitSet)(bits, 16, headerLen)) {
582
+ // STA
583
+ diLength += 7;
584
+ dataStartIndex += 7;
585
+ }
586
+ if ((0, common_1.isBitSet)(bits, 17, headerLen)) {
587
+ // PEM
588
+ diLength += 2;
589
+ dataStartIndex += 2;
590
+ }
591
+ if ((0, common_1.isBitSet)(bits, 18, headerLen)) {
592
+ // PEC
593
+ diLength += 7;
594
+ dataStartIndex += 7;
595
+ }
596
+ return diLength;
597
+ };
598
+ /**
599
+ * Primary Subfield를 통해 특정 Subfield가 추가
600
+ * Primary Subfield 최대 1개
601
+ * CAT 062: 500
602
+ * @param bitArr 바이트 값
603
+ * @param recordIndex record 시작 인덱스
604
+ * @returns 데이터 길이
605
+ */
606
+ const di500Len = (bitArr, recordIndex) => {
607
+ const { bits, headerLen } = (0, preprocess_1.parseIndicator)(bitArr, recordIndex);
608
+ let diLength = headerLen;
609
+ if ((0, common_1.isBitSet)(bits, 1, headerLen)) {
610
+ // APC
611
+ diLength += 4;
612
+ }
613
+ if ((0, common_1.isBitSet)(bits, 2, headerLen)) {
614
+ // COV
615
+ diLength += 2;
616
+ }
617
+ if ((0, common_1.isBitSet)(bits, 3, headerLen)) {
618
+ // APW
619
+ diLength += 4;
620
+ }
621
+ if ((0, common_1.isBitSet)(bits, 4, headerLen)) {
622
+ // AGA
623
+ diLength += 1;
624
+ }
625
+ if ((0, common_1.isBitSet)(bits, 5, headerLen)) {
626
+ // ABA
627
+ diLength += 1;
628
+ }
629
+ if ((0, common_1.isBitSet)(bits, 6, headerLen)) {
630
+ // ATV
631
+ diLength += 2;
632
+ }
633
+ if ((0, common_1.isBitSet)(bits, 7, headerLen)) {
634
+ // AA
635
+ diLength += 2;
636
+ }
637
+ if ((0, common_1.isBitSet)(bits, 8, headerLen)) {
638
+ // ARC
639
+ diLength += 1;
640
+ }
641
+ return diLength;
642
+ };
643
+ /**
644
+ * 마지막 비트를 보고 추가 확장이 있는지 판단
645
+ * CAT 062: 510
646
+ * @param bitArr 바이트 값
647
+ * @param recordIndex record 시작 인덱스
648
+ * @returns 데이터 길이
649
+ */
650
+ const di510Len = (bitArr, recordIndex) => {
651
+ let totalLen = 0;
652
+ // 현재 검사할 덩어리의 시작 위치
653
+ let currentPos = recordIndex;
654
+ let hasExtension = true;
655
+ while (hasExtension) {
656
+ // 3바이트 덩어리 중 마지막 바이트를 확인해야 함
657
+ const checkIndex = currentPos + 2;
658
+ // 배열 범위를 벗어나지 않는지 체크
659
+ if (checkIndex >= bitArr.length)
660
+ break;
661
+ const currentByte = bitArr[checkIndex];
662
+ hasExtension = (currentByte & 1) !== 0;
663
+ // 길이 3 누적
664
+ totalLen += 3;
665
+ // 다음 덩어리로 이동
666
+ currentPos += 3;
667
+ }
668
+ return totalLen;
669
+ };
670
+ /**
671
+ * 첫 번째 패킷 데이터를 보고 데이터 전체 길이를 유추
672
+ * SP, RE
673
+ * @param bitArr 바이트 값
674
+ * @param recordIndex record 시작 인덱스
675
+ * @returns 데이터 길이
676
+ */
677
+ const spAndReLen = (bitArr, recordIndex) => {
678
+ return bitArr[recordIndex];
679
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asterix-parser",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/chung5072/asterix-validator"