2 module.exports = x => {
3 if (typeof x !== 'string') {
4 throw new TypeError('Expected a string, got ' + typeof x);
7 // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
8 // conversion translates it to FEFF (UTF-16 BOM)
9 if (x.charCodeAt(0) === 0xFEFF) {