blob: b00feb9a440961c004d6eeaf297bd4cbd04d64a9 [file] [log] [blame]
Yang Guo4fd355c2019-09-19 08:59:031'use strict';
Paul Lewis75090cf2019-10-25 13:13:112module.exports = x => {
3 if (typeof x !== 'string') {
4 throw new TypeError('Expected a string, got ' + typeof x);
Yang Guo4fd355c2019-09-19 08:59:035 }
6
Paul Lewis75090cf2019-10-25 13:13:117 // 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) {
10 return x.slice(1);
Lorne Mitchelldb3885d2019-10-24 21:53:0111 }
12
Yang Guo4fd355c2019-09-19 08:59:0313 return x;
14};