Frontend/25_01_07/mai/node_modules/strip-bom/index.js
szabomarton 7f4a15b9c3 asd
2025-01-28 11:38:27 +01:00

16 lines
348 B
JavaScript

'use strict';
module.exports = string => {
if (typeof string !== 'string') {
throw new TypeError(`Expected a string, got ${typeof string}`);
}
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
// conversion translates it to FEFF (UTF-16 BOM)
if (string.charCodeAt(0) === 0xFEFF) {
return string.slice(1);
}
return string;
};