2 var isUtf8 = require('is-utf8');
4 module.exports = function (x) {
5 // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
6 // conversion translates it to FEFF (UTF-16 BOM)
7 if (typeof x === 'string' && x.charCodeAt(0) === 0xFEFF) {
11 if (Buffer.isBuffer(x) && isUtf8(x) &&
12 x[0] === 0xEF && x[1] === 0xBB && x[2] === 0xBF) {