Newer
Older
CVSS_3.0_GUI / dist / CVSS_3.0_Calc-1.0.0-linux-x64 / node_modules / nwjs-builder-phoenix / node_modules / yargs / node_modules / read-pkg-up / node_modules / read-pkg / node_modules / load-json-file / node_modules / strip-bom / index.js
root on 7 May 2019 407 bytes Initial commit
  1. 'use strict';
  2. var isUtf8 = require('is-utf8');
  3.  
  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) {
  8. return x.slice(1);
  9. }
  10.  
  11. if (Buffer.isBuffer(x) && isUtf8(x) &&
  12. x[0] === 0xEF && x[1] === 0xBB && x[2] === 0xBF) {
  13. return x.slice(3);
  14. }
  15.  
  16. return x;
  17. };
Buy Me A Coffee