(string)
| 1 | import { ParseRuntime } from "./ParseRuntime"; |
| 2 | function stripBom(string) { |
| 3 | if (typeof string !== 'string') { |
| 4 | throw new TypeError(`Expected a string, got ${typeof string}`); |
| 5 | } |
| 6 | |
| 7 | // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string |
| 8 | // conversion translates it to FEFF (UTF-16 BOM). |
| 9 | if (string.charCodeAt(0) === 0xFEFF) { |
| 10 | return string.slice(1); |
| 11 | } |
| 12 | |
| 13 | return string; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * For each data chunk coming to parser: |