1'use strict' 2 3module.exports = function (content) { 4 // Code also yanked from read-package-json. 5 function stripBOM (content) { 6 content = content.toString() 7 // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 8 // because the buffer-to-string conversion in `fs.readFileSync()` 9 // translates it to FEFF, the UTF-16 BOM. 10 if (content.charCodeAt(0) === 0xFEFF) return content.slice(1) 11 return content 12 } 13 14 return JSON.parse(stripBOM(content)) 15} 16