index.js 317 B

1234567891011121314
  1. 'use strict';
  2. module.exports = x => {
  3. if (typeof x !== 'string') {
  4. throw new TypeError('Expected a string, got ' + typeof x);
  5. }
  6. // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
  7. // conversion translates it to FEFF (UTF-16 BOM)
  8. if (x.charCodeAt(0) === 0xFEFF) {
  9. return x.slice(1);
  10. }
  11. return x;
  12. };