Commit a13a2cf
Fix: Buffer.from() in CRC helpers prevents browser/Deno/Bun execution (#444)
The Web APIs migration in c78b720 removed all Node.js Buffer usage so the
decoder runs cleanly in browser, Deno, Bun, and edge runtimes — but two
calls in the CRC-16 helpers (crc16IbmSdlcRev and crc16Genibus) were
missed. Both still called `Buffer.from(data, 'ascii')`, which is
undefined outside Node and would throw `ReferenceError: Buffer is not
defined` when ARINC 702 H1 checksum validation runs in non-Node
environments.
Fix: replace with a small inline `asciiStringToBytes()` helper that
walks the string and writes one byte per char into a Uint8Array (exactly
what `Buffer.from(s, 'ascii')` does). Same per-char masking with 0xff so
the byte values are identical.
Surfaced while centralizing the lib/utils/ helpers into the
airframes-decoder repo's runtimes/typescript/ for the upcoming
cross-language unification work; the runtime package's stricter tsconfig
caught the surviving Buffer references that the original repo's looser
config did not.
Verified: 23 Label_H1 test suites green (115/117 tests pass, 2 skipped
matching baseline).
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Mark Bumiller <mark.bumiller@gmail.com>1 parent f3dd9e2 commit a13a2cf
2 files changed
Lines changed: 2193 additions & 2451 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| |||
658 | 667 | | |
659 | 668 | | |
660 | 669 | | |
661 | | - | |
| 670 | + | |
662 | 671 | | |
663 | 672 | | |
664 | 673 | | |
| |||
689 | 698 | | |
690 | 699 | | |
691 | 700 | | |
692 | | - | |
| 701 | + | |
693 | 702 | | |
694 | 703 | | |
695 | 704 | | |
| |||
0 commit comments