(string)
| 577 | }; |
| 578 | |
| 579 | function stripBom(string) { |
| 580 | if (typeof string !== 'string') { |
| 581 | throw new TypeError(`Expected a string, got ${typeof string}`); |
| 582 | } |
| 583 | |
| 584 | // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string |
| 585 | // conversion translates it to FEFF (UTF-16 BOM). |
| 586 | if (string.charCodeAt(0) === 0xFEFF) { |
| 587 | return string.slice(1); |
| 588 | } |
| 589 | |
| 590 | return string; |
| 591 | } |
| 592 | |
| 593 | |
| 594 | module.exports = Converter; |