You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
275 B
15 lines
275 B
3 years ago
|
'use strict';
|
||
|
const isUtf8 = require('is-utf8');
|
||
|
|
||
|
module.exports = x => {
|
||
|
if (!Buffer.isBuffer(x)) {
|
||
|
throw new TypeError('Expected a Buffer, got ' + typeof x);
|
||
|
}
|
||
|
|
||
|
if (x[0] === 0xEF && x[1] === 0xBB && x[2] === 0xBF && isUtf8(x)) {
|
||
|
return x.slice(3);
|
||
|
}
|
||
|
|
||
|
return x;
|
||
|
};
|